Vue3 uses webpack bundle analyzer to analyze package files

1, install
NPM install -- save-dev webpack-bundle-analyzer
2, configure
vue.config.js

// 引入分析包文件
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

	// 开发生产共同配置
    config.plugins.push(
      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'
      })
    )

3, add

to scripts in package.json file

"analyz": "NODE_ENV=production npm_config_report=true npm run build"

4, just run, he will automatically open the analysis page

Read More: