先引入path :const CompressionPlugin= require('compression-webpack-plugin') //Gzip
module.expoers = { publicPath:'./', //使用相对路径打包 configureWebpack:{ plugins:[ new CompressionPlugin({ filename:'[path].gz[query]', algorithm:'gzip', test:new RegExp('\\.('+['js','css'].join('|')+')$'), threshold:8192, minRatio:0.8 }) ] } }
来源:oschina
链接:https://my.oschina.net/bing309/blog/3223237