打包分析配置

204 阅读1分钟

依赖包

{
  "resolutions": {
    "node-ipc": "9.2.1",
  },
  "devDependencies": {
    "webpack-bundle-analyzer": "4.5.0",
    "@types/webpack-bundle-analyzer": "3.9.4"
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  }
}

配置 vue.config.js

  • let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  • new BundleAnalyzerPlugin()
let BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
  devServer: {
    disableHostCheck: true,
    host: '0.0.0.0',
    watchOptions: {
        aggregateTimeout: 300,
        poll: 1000
    },
    proxy: {
    },
  },
  configureWebpack: {
    entry: ['babel-polyfill', './src/main.ts'],
    resolve: {
      symlinks: false,
    },
    module: {
    },
    plugins: [
      new BundleAnalyzerPlugin()
    ]
  },
  chainWebpack: (config) => {
    config.plugins.delete('fork-ts-checker');
  },
};