add generateAnalyzerReport

This commit is contained in:
Pan 2018-07-24 11:40:58 +08:00
parent 3da56b1a44
commit 7df8eaf064
2 changed files with 18 additions and 4 deletions

View File

@ -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

View File

@ -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
}
}