1. 配置 gzip 压缩,打出来一个gzip 后缀的文件
$ npm i compression-webpack-plugin -D
* vue.config.js 配置 const CompressionWebpackPlugin =
require('compression-webpack-plugin'); module.exports = { configureWebpack:
config => { if (process.env.NODE_ENV === 'production') { config.plugins.push(
...[ new CompressionWebpackPlugin({ filename: '[path].gz[query]', algorithm:
'gzip', test: /\.(js|css|html|svg)$/i, threshold: 2048, minRatio: 0.8 }) ] ); }
} };
2. webpack-bundle-analyzer 分析包
$ npm i webpack-bundle-analyzer -D