在项目中 webpack.prod.conf.js 进行配置:
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
执行 npm run build --report 后生成分析报告如下: