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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* DEVELOPMENT WEBPACK CONFIGURATION
*/
const path = require('path');
const CircularDependencyPlugin = require('circular-dependency-plugin');
module.exports = require('./webpack.base.babel')({
mode: 'development',
// Add hot reloading in development
entry: [
'webpack-hot-middleware/client?reload=true',
path.join(process.cwd(), 'src/app.js'), // Start with js/app.js
],
optimization: {
// namedModules: true,
// namedChunks: true,
chunkIds: 'named',
runtimeChunk: {
name: 'runtime',
},
splitChunks: {
name: false,
// eslint-disable-next-line no-irregular-whitespace
chunks: 'all', // all(全部), async(异步的模块),initial(同步的模块)
// eslint-disable-next-line no-irregular-whitespace
minSize: 20000, // 表示文件大于1k的时候才对它进行打包
// eslint-disable-next-line no-irregular-whitespace
minChunks: 2, // 当某个模块满足minChunks引用次数时,才会被打包。
// eslint-disable-next-line no-irregular-whitespace
maxAsyncRequests: 5, // 在打包某个模块的时候,最多分成5个chunk,多余的会合到最后一个chunk中
maxInitialRequests: Infinity,
automaticNameDelimiter: '~', // 当vendors或者default中的filename不填时,打包出来的文件名就会带~
cacheGroups: {
default: false,
vendors: {
// eslint-disable-next-line no-irregular-whitespace
// 将从node_modules中引入的模块统一打包到common.js文件中
name: 'common',
chunks: 'all',
minChunks: 2,
test: /[\\/]node_modules[\\/]/,
},
// styles: {
// // css统一打包到common.css文件中
// name: 'common',
// chunks: 'all',
// minChunks: 2,
// test: /\.(css|less|scss|stylus)$/,
// enforce: true,
// priority: 50,
// },
},
},
},
plugins: [
// new CircularDependencyPlugin({
// exclude: /node_modules/,
// include: /src/,
// failOnError: false,
// allowAsyncCycles: false,
// cwd: process.cwd(),
// }),
],
devtool: 'cheap-module-source-map',
node: {
setImmediate: false,
process: 'mock',
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
performance: {
hints: false,
},
});