diff --git a/_web/package.json b/_web/package.json index e8120365..73e63828 100644 --- a/_web/package.json +++ b/_web/package.json @@ -15,6 +15,7 @@ "axios": "^0.19.0", "babel-polyfill": "^6.26.0", "clipboard": "^2.0.6", + "compression-webpack-plugin": "5.0.1", "core-js": "^3.1.2", "crypto-js": "^4.0.0", "default-passive-events": "^1.0.10", diff --git a/_web/vue.config.js b/_web/vue.config.js index 0bd9a55d..89ade3b8 100644 --- a/_web/vue.config.js +++ b/_web/vue.config.js @@ -1,6 +1,8 @@ const path = require('path') const webpack = require('webpack') const createThemeColorReplacerPlugin = require('./config/plugin.config') +const CompressionWebpackPlugin = require('compression-webpack-plugin') +const productionGzipExtensions = ['js', 'css'] function resolve (dir) { return path.join(__dirname, dir) @@ -32,7 +34,14 @@ const vueConfig = { // webpack plugins plugins: [ // Ignore all locale files of moment.js - new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + // 配置compression-webpack-plugin压缩 + new CompressionWebpackPlugin({ + algorithm: 'gzip', + test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), + threshold: 10240, + minRatio: 0.8 + }) ], // if prod, add externals externals: isProd ? assetsCDN.externals : {}