Vue-cli3.0下Webpack对vue包压缩

话不多说直接上代码


如图这样会直接对js/html/css进行压缩

const CompressionPlugin = require('compression-webpack-plugin')
...

 configureWebpack: (config) => {
    if (process.env.NODE_ENV === 'production') {
      return {
        plugins: [

          new CompressionPlugin({
            test: /\.js$|\.html$|.\css/, // 匹配文件名
            threshold: 10240, // 对超过10k的数据压缩
            deleteOriginalAssets: false // 不删除源文件
          })
        ]
      }
    }
  },

你可能感兴趣的:(vue-cli3)