diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 53be22b6..6aa73904 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -67,7 +67,7 @@ const webpackConfig = merge(baseWebpackConfig, { }), new ScriptExtHtmlWebpackPlugin({ //`runtime` must same as runtimeChunk name. default is `runtime` - inline:/runtime\..*\.js$/ + inline: /runtime\..*\.js$/ }), // keep module.id stable when vender modules does not change new webpack.HashedModuleIdsPlugin(), @@ -151,9 +151,22 @@ if (config.build.productionGzip) { ) } -if (config.build.bundleAnalyzerReport) { +if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) { const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin - webpackConfig.plugins.push(new BundleAnalyzerPlugin()) + + if (config.build.bundleAnalyzerReport) { + webpackConfig.plugins.push(new BundleAnalyzerPlugin({ + analyzerPort: 8080, + generateStatsFile: false + })) + } + + if (config.build.generateAnalyzerReport) { + webpackConfig.plugins.push(new BundleAnalyzerPlugin({ + analyzerMode: 'static', + openAnalyzer: false + })) + } } module.exports = webpackConfig diff --git a/config/index.js b/config/index.js index 92c4a172..ca7c005d 100644 --- a/config/index.js +++ b/config/index.js @@ -86,6 +86,7 @@ module.exports = { // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report + bundleAnalyzerReport: process.env.npm_config_report || false, + generateAnalyzerReport: process.env.npm_config_generate_report || false } }