-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwebpack.config.js
51 lines (50 loc) · 1.62 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
const path = require('path')
const MyPlugin = require('./plugins/myplugin-4.js')
const Listen4Myplugin = require('./plugins/listen4myplugin.js')
module.exports = {
mode: 'development',
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: path.resolve('./loaders/index.js'),
options: {
test: 1
}
}
}]
},
optimization: {
runtimeChunk: { name: 'common/runtime' },
splitChunks: {
cacheGroups: {
vendor: { // 抽离第三方插件
test: /node_modules/, // 指定是node_modules下的第三方包
chunks: 'initial',
name: 'common/vendor', // 打包后的文件名,任意命名
priority: 10 // 设置优先级,防止和自定义的公共代码提取时被覆盖,不进行打包
},
utils: { // 抽离自定义公共代码
test: /\.js$/,
chunks: 'initial',
name: 'common/utils',
minSize: 0 // 只要超出0字节就生成一个新包
}
}
}
},
plugins: [
new MyPlugin("Plugin is instancing."),
new Listen4Myplugin()
]
}