1.安装webpack-bundle-analyzer插件
``
sudo yarn add webpack-bundle-analyzer --dev
``
2.配置vue.config.js
constBundleAnalyzerPlugin=require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
if(process.env.use_analyzer){
config.plugins.push(
new BundleAnalyzerPlugin()
);
}
} else {
// 为开发环境修改配置...
}
},
3.package.json
//"analyze": "npm run build --report"
"analyze": "use_analyzer=true npm run build_mymeetings" //加判断
网友评论