|
@@ -1,6 +1,8 @@
|
|
|
'use strict'
|
|
|
const path = require('path')
|
|
|
const defaultSettings = require('./src/settings.js')
|
|
|
+const CompressionPlugin = require('compression-webpack-plugin');
|
|
|
+
|
|
|
|
|
|
function resolve(dir) {
|
|
|
return path.join(__dirname, dir)
|
|
@@ -57,7 +59,17 @@ module.exports = {
|
|
|
alias: {
|
|
|
'@': resolve('src')
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ plugins: [
|
|
|
+
|
|
|
+ new CompressionPlugin({
|
|
|
+ algorithm: 'gzip', // 使用gzip压缩
|
|
|
+ test: /\.js$|\.html$|\.css$/, // 匹配文件名
|
|
|
+ minRatio: 0.8, // 压缩率小于0.8才会压缩
|
|
|
+ threshold: 10240, // 对超过10k的数据压缩
|
|
|
+ deleteOriginalAssets: false // 是否删除未压缩的源文件,谨慎设置,如果希望提供非gzip的资源,可不设置或者设置为false(比如删除打包后的gz后还可以加载到原始资源文件)
|
|
|
+ })
|
|
|
+ ]
|
|
|
},
|
|
|
chainWebpack(config) {
|
|
|
// it can improve the speed of the first screen, it is recommended to turn on preload
|