-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
39 lines (35 loc) · 987 Bytes
/
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
const path = require('path');
const { getRules, getPlugings } = require('./config/webpack.parts');
const devLoaders = ['css', 'sass', 'less', 'images', 'fonts', 'videos'];
const prodLoaders = ['css', 'sass', 'less', 'images', 'fonts', 'videos'];
const devPlugings = ['clean', 'html'];
const prodPlugings = ['clean', 'html'];
module.exports = env => {
const rules =
env.NODE_ENV === 'production'
? getRules(prodLoaders)
: getRules(devLoaders);
const plugins =
env.NODE_ENV === 'production'
? getPlugings(prodPlugings)
: getPlugings(devPlugings);
return {
mode: env.NODE_ENV,
entry: path.resolve(__dirname, 'src', 'entry.js'),
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js',
},
module: {
rules,
},
plugins,
devServer: {
contentBase: path.resolve(__dirname, './dist'),
hotOnly: true,
overlay: true,
port: 3000,
host: '0.0.0.0',
},
};
};