vue cli打包文件优化工具 webpack-bundle-analyzer

  • 安装webpack-bundle-analyzer插件

    npm intall webpack-bundle-analyzer –save-dev

  • 在build/webpack.prod.config.js中添加配置

    if (config.build.bundleAnalyzerReport) {
        const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
        webpackConfig.plugins.push(new BundleAnalyzerPlugin());
    }
  • 在package.json的scripts中添加配置

    “analyz”: “NODE_ENV=production npm_config_report=true npm run build”

  • 运行命令

    npm run analyz

  • 运行结果

    vue cli打包文件优化工具 webpack-bundle-analyzer_第1张图片

你可能感兴趣的:(vue cli打包文件优化工具 webpack-bundle-analyzer)