-
Notifications
You must be signed in to change notification settings - Fork 40
/
webpack.config.js
55 lines (50 loc) · 1.21 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
const webpack = require('webpack');
const path = require('path');
const config = require('./config');
const JS_DEV = path.resolve(config.root.dev, config.js.dev);
const JS_DIST = path.resolve(config.root.dist, config.js.dist);
const webpackConfig = {
mode: config.production ? 'production' : 'development',
optimization: {
minimize: config.production
},
context: JS_DEV,
entry: {
app: [
'./index.js',
],
},
output: {
path: JS_DIST,
filename: 'main.js',
publicPath: config.production ? '' : config.browserSync.proxy.publicPath,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
],
},
resolve: {
modules: [
JS_DEV,
'node_modules',
],
extensions: ['.js', '.json'],
},
plugins: [],
};
/** Modifies webpackConfig depends on mode. */
if (config.production) {
webpackConfig.plugins.push(
new webpack.NoEmitOnErrorsPlugin(),
);
} else {
webpackConfig.devtool = 'inline-source-map';
webpackConfig.entry.app.unshift('webpack-hot-middleware/client?reload=true');
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = webpackConfig;