From 50c9dc3863e0dd5e3ac41c4009349fa952dfb84a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 16 三月 2026 13:47:35 +0800
Subject: [PATCH] Merge branch 'dev_衡阳_鹏创电子' of http://114.132.189.42:9002/r/product-inventory-management into dev_衡阳_鹏创电子

---
 vite.config.js |   71 +++++++++++++++++------------------
 1 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/vite.config.js b/vite.config.js
index ca514f6..33debfd 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -2,7 +2,6 @@
 import path from "path";
 import createVitePlugins from "./vite/plugins";
 
-// https://vitejs.dev/config/
 export default defineConfig(({ mode, command }) => {
   const env = loadEnv(mode, process.cwd());
   const { VITE_APP_ENV } = env;
@@ -19,55 +18,65 @@
     define: {
       __BASE_API__: JSON.stringify(javaUrl),
     },
-    base: VITE_APP_ENV === "production" ? "/" : "/",
+    base: "/",
     plugins: createVitePlugins(env, command === "build"),
+
     resolve: {
       alias: {
         "~": path.resolve(__dirname, "./"),
         "@": path.resolve(__dirname, "./src"),
       },
       extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
-      dedupe: ["vue", "axios"], // 鍘婚噸閲嶅渚濊禆
+      dedupe: ["vue", "axios"],
     },
-    // 鍏ㄥ眬寮�鍚瀯寤虹紦瀛橈紙鏍稿績锛�
-    cacheDir:
-      "/var/jenkins_home/workspace/瀹㈡埛-楣忓垱鐢靛瓙鍓嶇/node_modules/.vite",
-    // 渚濊禆棰勬瀯寤轰紭鍖�
+
+    // 缂撳瓨璺緞鏀逛负鐩稿璺緞锛孞enkins 缁濆璺緞鏋佸鏄撴姤閿�
+    cacheDir: "node_modules/.vite",
+
     optimizeDeps: {
-      include: ["vue", "axios", "element-plus", "echarts"], // 鏍规嵁椤圭洰渚濊禆璋冩暣
+      include: ["vue", "axios", "element-plus", "echarts"],
       esbuildOptions: {
         target: "es2020",
       },
     },
-    // 鎵撳寘閰嶇疆锛堟牳蹇冧紭鍖栧尯锛�
+
     build: {
-      sourcemap: false, // 褰诲簳鍏抽棴鐢熶骇鐜sourcemap
+      sourcemap: false,
       outDir: "dist",
       assetsDir: "assets",
       chunkSizeWarningLimit: 2000,
-      minify: "esbuild", // 浣跨敤 esbuild 鍘嬬缉锛堟棤闇�棰濆渚濊禆锛�
-      reportCompressedSize: false, // 鍏抽棴浜х墿浣撶Н鎶ュ憡锛屽噺灏戣�楁椂
-      commonjsOptions: {
-        include: [/node_modules/, /\.commonjs$/],
-      },
+      minify: "esbuild",
+      reportCompressedSize: false,
+
       rollupOptions: {
         output: {
           chunkFileNames: "static/js/[name]-[hash].js",
           entryFileNames: "static/js/[name]-[hash].js",
           assetFileNames: "static/[ext]/[name]-[hash].[ext]",
-          // 鍒嗗寘绛栫暐锛堟媶鍒嗗ぇ渚濊禆锛�
-          manualChunks: {
-            vendor: ["vue", "vue-router", "pinia", "axios"],
-            ui: ["element-plus"], // 鏍规嵁瀹為檯UI搴撹皟鏁�
-            charts: ["echarts"], // 鏈夊浘琛ㄥ簱鍒欎繚鐣欙紝鏃犲垯鍒犻櫎
+          manualChunks(id) {
+            // 鏇寸ǔ瀹氱殑鑷姩鍒嗗寘锛岄伩鍏嶄綘涔嬪墠鍐欐鍒嗗寘瀵艰嚧寰幆渚濊禆
+            if (
+              id.includes("node_modules/vue") ||
+              id.includes("node_modules/vue-router") ||
+              id.includes("node_modules/pinia") ||
+              id.includes("node_modules/axios")
+            ) {
+              return "vendor";
+            }
+            if (id.includes("node_modules/element-plus")) {
+              return "ui";
+            }
+            if (id.includes("node_modules/echarts")) {
+              return "charts";
+            }
           },
         },
-        cache: true,
       },
     },
+
     server: {
       port: 8001,
-      host: true,
+      host: "0.0.0.0",
       open: true,
       proxy: {
         "/dev-api": {
@@ -75,12 +84,13 @@
           changeOrigin: true,
           rewrite: (p) => p.replace(/^\/dev-api/, ""),
         },
-        "^/v3/api-docs/(.*)": {
+        "/v3/api-docs": {
           target: baseUrl,
           changeOrigin: true,
         },
       },
     },
+
     css: {
       postcss: {
         plugins: [
@@ -88,25 +98,14 @@
             postcssPlugin: "internal:charset-removal",
             AtRule: {
               charset: (atRule) => {
-                if (atRule.name === "charset") {
-                  atRule.remove();
-                }
+                if (atRule.name === "charset") atRule.remove();
               },
             },
           },
         ],
       },
-      // CSS 棰勭紪璇戠紦瀛�
-      preprocessorOptions: {
-        scss: {
-          cacheDirectory: path.resolve(
-            __dirname,
-            "./node_modules/.vite/scss-cache"
-          ),
-        },
-      },
     },
-    // esbuild 鍏ㄥ眬閰嶇疆
+
     esbuild: {
       logOverride: { "this-is-undefined-in-esm": "silent" },
       target: "es2020",

--
Gitblit v1.9.3