gzip - ythy/blog GitHub Wiki
use compression-webpack-plugin
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240, //Only assets bigger than this size are processed. In bytes.
minRatio: 0.8 //Only assets that compress better that this ratio are processed
})
在 webpack-dev-server 中启用 gzip压缩:
devServer: {
compress: true,
},
output : {
filename : XX
}
the browser tells the server if it supports GZip, if it does, it sends the .gz version of the file, else it sends the text version. The browser decodes the file, and loads it into the html. All you see is the decoded version.
You don’t have to worry about GZIP browser support, as many have supported it for over 17 years.
- Internet Explorer 5.5+ (July 2000)
- Opera 5+ (June 2000)
- Firefox 0.9.5+ (October 2001)
- Chrome (soon after launch in 2008)
- Safari (soon after first launch in 2003)