1.下载

  yarn add webpack-bundle-analyzer -D

2.配置package.json

 "analyz": "cross-env NODE_ENV=production npm_config_report=true npm run build"

3.webpack配置

    if (process.env.npm_config_report) {

      const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

      webpackConfig.plugins.push(new BundleAnalyzerPlugin())

    }

4.默认会打开

  http://127.0.0.1:8888/

1583744858(1).png