From aab6a7b8d43339480cbf0b33ea1309fd901dafdb Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 10 六月 2025 15:03:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1
---
company/vue.config.js | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/company/vue.config.js b/company/vue.config.js
index e92b8dc..336dec7 100644
--- a/company/vue.config.js
+++ b/company/vue.config.js
@@ -1,6 +1,7 @@
// 璇︾粏閰嶇疆璇峰弬鑰僪ttps://cli.vuejs.org/zh/config/#vue-config-js
// const outputDir = process.env.VUE_APP_CONTEXT_PATH.substring(1, process.env.VUE_APP_CONTEXT_PATH.length - 1)
// const outputDir = process.env.VUE_APP_CONTEXT_PATH.substring(1, process.env.VUE_APP_CONTEXT_PATH.length)
+const CompressionPlugin = require('compression-webpack-plugin')
module.exports = {
publicPath: './',
outputDir: process.env.VUE_APP_CONTEXT_NAME,
@@ -18,5 +19,40 @@
}
}
}
+ },
+ configureWebpack: config => {
+ // if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test') {
+ return {
+ plugins: [
+ new CompressionPlugin({
+ algorithm: 'gzip', // 浣跨敤gzip鍘嬬缉
+ test: /\.(js|css|html)$/, // 鍖归厤鏂囦欢绫诲瀷
+ threshold: 10240, // 鍙鐞嗘瘮杩欎釜鍊煎ぇ鐨勮祫婧愩�傚�兼槸瀛楄妭锛�10240瀛楄妭=10KB
+ minRatio: 0.8 // 鍘嬬缉姣旂巼锛屽彧鏈夊帇缂╃巼灏忎簬杩欎釜鍊肩殑璧勬簮鎵嶄細琚鐞�
+ })
+ ],
+ optimization: {
+ runtimeChunk: 'single',
+ splitChunks: {
+ chunks: 'all',
+ maxInitialRequests: Infinity,
+ minSize: 20000,
+ cacheGroups: {
+ vendors: {
+ test: /[\\/]node_modules[\\/]/, // 浣跨敤姝e垯鍖归厤node_modules涓紩鍏ョ殑妯″潡
+ priority: -10, // 浼樺厛绾у�艰秺澶т紭鍏堢骇瓒婇珮锛岄粯璁�-10锛屼笉鐢ㄤ慨鏀�
+ name(module) {
+ // 璁惧畾鍒嗗寘浠ュ悗鐨勬枃浠舵ā鍧楀悕瀛楋紝鎸夌収鍖呭悕瀛楁浛鎹㈡嫾鎺ヤ竴涓�
+
+ if (!module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)) return;
+ const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
+ return `npm.${packageName.replace('@', '')}`;
+ }
+ }
+ }
+ }
+ }
+ }
+ // }
}
}
--
Gitblit v1.9.3