2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
npm i compression-webpack-plugin -D
const CompressionPlugin = require('compression-webpack-plugin')
module.exports = {
configureWebpack: {
plugins: [
new CompressionPlugin({
test: /.js$|.html$|.css/,
threshold: 10240 // 只处理比这个值大的资源。按字节计算 设置的是 10kb
})
]
}
}
You can see that the 1.2M vendors file is compressed to 295k, and the web page running speed is improved.
It can be opened within s.
If the style is not recognized, the CSS file will not be compressed. This function requires the backend to enable gzip so that such files can be recognized.