我搭建的是一个单页应用想用webpack4下的splitChunks功能想将node_modules引用的模块比如vue之类的提取放到一个js文件下但是怎么提都提不出来一点反应都没有,这是怎么回事?optimization: {
splitChunks: {
chunks: 'initial', //默认只作用于异步模块,为`all`时对所有模块生效,`initial`对同步模块有效
minSize: 30000, //合并前模块文件的体积
minChunks: 1, //最少被引用次数
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
cacheGroups: {
vendors: {
test: /node_modules/,
minChunks: 1,
priority: -10
},
default: {
test: /src/,
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
2 回答
慕容708150
TA贡献1831条经验 获得超4个赞
找到问题的原因了,是加了下面这个东西
导致和splitChunks
有冲突
new webpack.optimize.MinChunkSizePlugin({minChunkSize: 30000}),
白衣染霜花
TA贡献1796条经验 获得超10个赞
splitChunks: { cacheGroups: { manifest: { name: "manifest", chunks: "initial", minChunks: 2 }, vendor: { chunks: "all", test: /[\\/]node_modules[\\/]/, name: "vendor", minChunks: 1, maxInitialRequests: 5, minSize: 0, priority: 98 } } } },
添加回答
举报
0/150
提交
取消