-
Notifications
You must be signed in to change notification settings - Fork 23
/
webpack.config.js
61 lines (56 loc) · 1.68 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
/**
* If the "--production" command-line parameter is specified when invoking Heft, then the
* "production" function parameter will be true. You can use this to enable bundling optimizations.
*/
function createWebpackConfig({ production }) {
const webpackConfig = {
// Documentation: https://webpack.js.org/configuration/mode/
mode: production ? 'production' : 'development',
resolve: {
extensions: ['.js', '.jsx', '.json']
},
module: {
rules: [
{
test: /\.css$/,
use: [require.resolve('style-loader'), require.resolve('css-loader')]
},
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader']
}
]
},
entry: {
app: path.join(__dirname, 'lib', 'index.js'),
// Put these libraries in a separate vendor bundle
vendor: ['react', 'react-dom']
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]_[contenthash].js'
},
performance: {
// This specifies the bundle size limit that will trigger Webpack's warning saying:
// "The following entrypoint(s) combined asset size exceeds the recommended limit."
maxEntrypointSize: 250000,
maxAssetSize: 250000
},
devServer: {
port: 9000
},
devtool: production ? undefined : 'source-map',
plugins: [
// See here for documentation: https://github.com/jantimon/html-webpack-plugin
new HtmlWebpackPlugin({
template: 'assets/index.html'
})
]
};
return webpackConfig;
}
module.exports = createWebpackConfig;