The installation

    npm install --save-dev webpack-bundle-analyzer
Copy the code

Configuration (webpack.config.js)

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; Plugins: [new BundleAnalyzerPlugin({analyzerMode: 'server', analyzerHost: '127.0.0.1', analyzerPort: 8888, reportFilename: 'report.html', defaultSizes: 'parsed', openAnalyzer: true, generateStatsFile: false, statsFilename: 'stats.json', statsOptions: null, logLevel: 'info' } ), ]Copy the code

In the package. Add json

    "analyz": "NODE_ENV=production npm_config_report=true npm run build"
Copy the code

run

npm run analyzCopy the code