create-react-app 搭建的项目中,引入 webpack-bundle-analyzer 打包分析

  1. 安装npm intall webpack-bundle-analyzer --save-dev
  2. config/webpack.config.dev.js 文件中,添加

    const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
    module.exports = {
      plugins: [
        ...
        new BundleAnalyzerPlugin()
      ]
    }
  3. 运行npm run dev,打包分析页面:http://127.0.0.1:8888/

猜你喜欢

转载自www.cnblogs.com/cag2050/p/9184352.html