SplitChunksPlugin
来源:3-5 webpack对脚本和样式的处理

包肉的锅
2020-11-09
请问老师SplitChunksPlugin 如何配置全局common模块
var config = {
entry: {
‘common’: [’./src/page/common/index.js’],
‘index’ : [’./src/page/index/index.js’],
‘login’ : [’./src/page/login/index.js’]
},
output: {
path: ‘C:/Users/无肉不欢/Desktop/网智项目管理/上市培育企业资源库管理平台/LERMP-fe/dist’,
filename: ‘js/[name].js’
},
externals : {
‘jquery’ : ‘window.jQuery’
},
optimization: {
splitChunks: {
chunks: ‘all’,
minChunks: 2,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: ‘~’,
cacheGroups: {
vendors: {
test: /[\/]node_modules[\/]/,
filename: ‘./js/vendor.js’,// 分离包的名字
priority: -10
},
common: { // 打包其余的的公共代码
test: /[\/]src[\/]/,
filename: ‘./js/common.js’,// 分离包的名字
priority: 5
}
}
}
}
};
这样配置会报错:
1回答
-
群共享里有一个升级webpack@4.x的代码包,可以参考里面的配置
032020-11-14