splitChunks: {
chunks: 'all',
minSize: 30000, // 分割文件大小 相当于大于30KB
maxSize: 0, // 分割限制最小大小 0不限制
minChunks: 1, // 最小引入模块次数 满足才会被分割
maxAsyncRequests: 6, // 最多分割? 5
maxInitialRequests: 4, // 入口文件引入的库进行的代码分割 3
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -8,
filename: 'chunks/common.js'
},
echarts: {
test: /[\\/]echarts[\\/]/,
priority: -5,
filename: 'chunks/echarts.js',
reuseExistingChunk: true
},
elementUi: {
test: /[\\/]element-ui[\\/]/,
priority: 0,
filename: 'chunks/elementUi.js',
reuseExistingChunk: true
},
default: {
minChunks: 1,
priority: -9,
filename: 'js/default.[contenthash].js',
reuseExistingChunk: true
}
}
}
webpack 4.30 vue-cli3.x