From 7a0437a70aecd12b9702aedc6095b217bfcfee6c Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 27 Nov 2024 12:17:46 +0800
Subject: [PATCH] 打包压缩配置

---
 vite.config.js |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/vite.config.js b/vite.config.js
index aae870f..2c46e25 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -16,6 +16,7 @@
 import AutoImport from 'unplugin-auto-import/vite'
 import basicSsl from '@vitejs/plugin-basic-ssl'
 import { fa } from 'element-plus/es/locales.mjs'
+import viteCompression from 'vite-plugin-compression'
 
 export default ({ mode, command }) => {
   const env = loadEnv(mode, process.cwd())
@@ -53,7 +54,14 @@
       basicSsl(),
       AutoImport({
         imports: ["vue", "vue-router"], // 自动导入vue和vue-router相关函数
-      })
+      }),
+      viteCompression({
+	      filter: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i, // 需要压缩的文件
+	      threshold: 512, // 文件容量大于这个值进行压缩
+	      algorithm: 'gzip', // 压缩方式
+	      ext: 'gz', // 后缀名
+	      deleteOriginFile: true, // 压缩后是否删除压缩源文件
+    	})
     ],
 
     css: {

--
Gitblit v1.9.3