1. 程式人生 > >[Vue CLI 3] 配置 webpack-bundle-analyzer 外掛

[Vue CLI 3] 配置 webpack-bundle-analyzer 外掛

1、
//安裝
cnpm intall webpack-bundle-analyzer –save-dev


2、
// vue.config.js

const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      return {
        plugins: [
          new BundleAnalyzerPlugin()
        ]
      }
    }
  }

3、
// package.json
 "analyz": "npm_config_report=true npm run build"

4、
npm run analyz    //預設8888  埠