1234567891011121314151617 |
- // gzip压缩
- const CompressionWebpackPlugin = require('compression-webpack-plugin') // 开启压缩
- module.exports = {
- productionSourceMap: false,
- configureWebpack: config => {
- config.plugins.push(
- new CompressionWebpackPlugin({
- filename: '[path].gz[query]',
- algorithm: 'gzip',
- test: /\.js$|\.html$|.\css/,
- threshold: 10240, // 只有大小大于该值的资源会被处理 10240
- minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
- deleteOriginalAssets: false // 删除原文件
- })
- )
- }
- }
|