yarn add webpack-bundle-analyzer
修改webpack.config.js:
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const isBundleAnalyzer = process.env.GENERATE_BUNDLE_ANALYZER_REPORT === 'true'
plugins: [
// ...
isEnvProduction && isBundleAnalyzer && new BundleAnalyzerPlugin()
]
通过设置环境变量GENERATE_BUNDLE_ANALYZER_REPORT=true来生成report
本文摘自 :https://blog.51cto.com/x