环境:vue-cli4、webpack4、nodejs@12.18.3
安装: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之后:

网友评论