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()
]
通過設置環(huán)境變量GENERATE_BUNDLE_ANALYZER_REPORT=true來生成report
?
?
?
?
?
本文摘自 :https://blog.51cto.com/x