原创不易,未经作者允许禁止转载!!
分享时间和文件的分析工具,便于进行打包优化。
npm i speed-measure-webpack-plugin
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin")
const smp = new SpeedMeasurePlugin()
module.exports = function (env) {
const isProduction = env.production;
process.env.NODE_ENV = isProduction ? "production" : "development"
const config = isProduction ? prodConfig : devConfig
const webpackConfig = merge(commonConfig(isProduction), config)
return smp.wrap(webpackConfig)
}
"stats": "webpack --config ./config/webpack.common.js --env production --profile --json=stats.json",
npm install webpack-bundle-analyzer
const {BundleAnalyzerPlugin} = require("webpack-bundle-analyzer")
plugins:[
new BundleAnalyzerPlugin()
]