当前位置:首页 > IT技术 > 移动平台 > 正文

create-react-app 生成 report.html 可视化打包分析
2021-09-17 16:18:00

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

 

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

 
 
 
 

本文摘自 :https://blog.51cto.com/x