vue.config.js 556 B

1234567891011121314151617
  1. // gzip压缩
  2. const CompressionWebpackPlugin = require('compression-webpack-plugin') // 开启压缩
  3. module.exports = {
  4. productionSourceMap: false,
  5. configureWebpack: config => {
  6. config.plugins.push(
  7. new CompressionWebpackPlugin({
  8. filename: '[path].gz[query]',
  9. algorithm: 'gzip',
  10. test: /\.js$|\.html$|.\css/,
  11. threshold: 10240, // 只有大小大于该值的资源会被处理 10240
  12. minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
  13. deleteOriginalAssets: false // 删除原文件
  14. })
  15. )
  16. }
  17. }