可视化打包分析工具 webpack-bundle-analyzer

环境:vue-cli4、webpack4、[email protected]

安装:npm install webpack-bundle-analyzer --save-dev

vue.config.js 配置:

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
  chainWebpack(config) {
    if (isProduction) {
      config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
        {
          analyzerMode: 'static'
        }
      ])
    }
  }
}

build之后:

report.html.jpg

你可能感兴趣的:(可视化打包分析工具 webpack-bundle-analyzer)