From eb166b58c161e0b7da00ea42b0db66c326319b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com> Date: Fri, 13 Aug 2021 20:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=8A=A0=E8=BD=BD=E9=A6=96=E9=A1=B5loading=E6=85=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=9B=B4=E5=A4=9A=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E8=A7=81=E6=96=87=E6=A1=A3=EF=BC=88https://d?= =?UTF-8?q?oc.xiaonuo.vip=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _web/package.json | 1 + _web/vue.config.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 : {}