1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-09-10 21:30:14 +08:00

refine prod config

This commit is contained in:
Pan 2018-08-03 17:31:44 +08:00
parent 2e517317ad
commit 91fb10b7b3

View File

@ -96,33 +96,21 @@ const webpackConfig = merge(baseWebpackConfig, {
chunks: 'all', chunks: 'all',
cacheGroups: { cacheGroups: {
libs: { libs: {
name: 'libs', name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: 'initial' chunks: 'initial' // 只打包初始时依赖的第三方
}, },
elementUI: { elementUI: {
name: 'chunk-elementUI', name: 'chunk-elementUI', // 单独将 elementUI 拆包
priority: 20, priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
test: /[\\/]node_modules[\\/]element-ui[\\/]/ test: /[\\/]node_modules[\\/]element-ui[\\/]/
}, },
echarts: { commons: {
name: 'chunk-echarts', name: 'chunk-comomns',
priority: 20, test: resolve("src/components"), // 可自定义拓展你的规则
test: function (module) { minChunks: 3, // 最小公用次数
var context = module.context; priority: 5,
return context && (context.indexOf('echarts') >= 0 || context.indexOf('zrender') >= 0)
}
},
xlsx: {
name: 'chunk-xlsx',
priority: 20,
test: /[\\/]node_modules[\\/]xlsx[\\/]/
},
codemirror: {
name: 'chunk-codemirror',
priority: 20,
test: /[\\/]node_modules[\\/]codemirror[\\/]/
}, },
} }
}, },
@ -176,6 +164,7 @@ if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) {
if (config.build.generateAnalyzerReport) { if (config.build.generateAnalyzerReport) {
webpackConfig.plugins.push(new BundleAnalyzerPlugin({ webpackConfig.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'static', analyzerMode: 'static',
reportFilename:'bundle-report.html',
openAnalyzer: false openAnalyzer: false
})) }))
} }