splitChunksPlugin默认配置
https://webpack.js.org/plugins/split-chunks-plugin/
默认配置:
optimization: {
splitChunks: {
chunks: 'async', //只对异步引入模块进行代码分割
minSize: 30000,//只对大于30000的模块进行异步分割
minRemainingSize: 0,
maxSize: 0,
minChunks: 1,//模块引入此时至少1次才会进行代码分割
maxAsyncRequests: 6,
maxInitialRequests: 4,
automaticNameDelimiter: '~',//代码分割命名分割符
automaticNameMaxLength: 30,
cacheGroups: { //缓存组,模块满足上面条件还不够,必须满足下面某组条件才会被代码分割
vendors: {
test: /[\\/]node_modules[\\/]/, //模块是不是在node_modules里面
priority: -10 //优先级,该值越大,优先级越高
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true //之前引入的模块已经把后续引入的模块已经进行代码分割了,不再重复分割
}
}
}
}