Gzip compression doesn't work in a angular 5 project which uses webpack 3.10.0 after hosting in iis. The plugins I have tried are compression-webpack-plugin@1.0.0 and brotli-gzip-webpack-plugin.
Shown below is a sample code and the plugins are included in production configs.
const BrotliGzipPlugin = require('brotli-gzip-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = {
plugins: [
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js|html)$/,
threshold: 10240,
minRatio: 0.8
}),
new BrotliGzipPlugin({
asset: '[path].br[query]',
algorithm: 'brotli',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
}),
new BrotliGzipPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
})
]
}
It was expected to load a smaller size of the files and include something similar to content-encoding: gzip in response headers.
- Why aren't the files replaced with gz version in prod mode?
- Could there be any IIS configuration for this to work?
This is how my build looks, it has gzip, brotli files as well.