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