create-react-app 生成 report.html 可视化打包分析

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://www.cnblogs.com/xutongbao/p/15264345.html