From c5c6fa800cedd37cea0e3cc3e68df78b47ee2813 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 28 八月 2023 10:37:59 +0800
Subject: [PATCH] 111

---
 screen_standard/vite.config.js |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/screen_standard/vite.config.js b/screen_standard/vite.config.js
index 7947ffa..bf4e9bc 100644
--- a/screen_standard/vite.config.js
+++ b/screen_standard/vite.config.js
@@ -4,14 +4,28 @@
 import vue from '@vitejs/plugin-vue'
 import vueJsx from '@vitejs/plugin-vue-jsx'
 
+import AutoImport from 'unplugin-auto-import/vite'
+import Components from 'unplugin-vue-components/vite'
+import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
+
 // https://vitejs.dev/config/
 export default defineConfig(({mode, command}) => {
   let env = loadEnv(mode, process.cwd(), '')
-  console.log(env.NODE_ENV);
+  // console.log('-------');
+  // console.log(env.VITE_BASE_PATH);
+  // console.log(env.VITE_BASE_PATH.replace(env.VITE_BASE_PATH, ''));
+  // console.log('-------');
   return {
+    base:env.VITE_BASE_CONTEXT,
     plugins: [
       vue(),
       vueJsx(),
+      AutoImport({
+        resolvers: [ElementPlusResolver()],
+      }),
+      Components({
+        resolvers: [ElementPlusResolver()],
+      }),
     ],
     resolve: {
       alias: {
@@ -21,22 +35,25 @@
     // 鎵撳寘閰嶇疆
     build: {
       target: 'modules',
-      outDir: 'dist', //鎸囧畾杈撳嚭璺緞
+      outDir: env.VITE_BASE_CONTEXT, //鎸囧畾杈撳嚭璺緞
       assetsDir: 'assets', // 鎸囧畾鐢熸垚闈欐�佽祫婧愮殑瀛樻斁璺緞
       minify: 'terser' // 娣锋穯鍣紝terser鏋勫缓鍚庢枃浠朵綋绉洿灏�
     },
   
     // 鏈湴杩愯閰嶇疆锛屽強鍙嶅悜浠g悊閰嶇疆
     server: {
+      host: '192.168.0.3',
+      port: '8080',
       cors: true, // 榛樿鍚敤骞跺厑璁镐换浣曟簮
       open: true, // 鍦ㄦ湇鍔″櫒鍚姩鏃惰嚜鍔ㄥ湪娴忚鍣ㄤ腑鎵撳紑搴旂敤绋嬪簭
       //鍙嶅悜浠g悊閰嶇疆锛屾敞鎰弐ewrite鍐欐硶锛屽紑濮嬫病鐪嬫枃妗e湪杩欓噷韪╀簡鍧�
-      proxy: {// 鏈湴寮�鍙戠幆澧冮�氳繃浠g悊瀹炵幇璺ㄥ煙锛岀敓浜х幆澧冧娇鐢� nginx 杞彂
-        '/api': {
-          target: 'http://localhost/3000', // 閫氳繃浠g悊鎺ュ彛璁块棶瀹為檯鍦板潃銆傝繖閲屾槸瀹為檯璁块棶鐨勫湴鍧�銆倂ue浼氶�氳繃浠g悊鏈嶅姟鍣ㄦ潵浠g悊璇锋眰
+      proxy: {  // 鏈湴寮�鍙戠幆澧冮�氳繃浠g悊瀹炵幇璺ㄥ煙锛岀敓浜х幆澧冧娇鐢� nginx 杞彂
+        [env.VITE_BASE_PATH] : {
+          target: env.VITE_BASE_URL, // 閫氳繃浠g悊鎺ュ彛璁块棶瀹為檯鍦板潃銆傝繖閲屾槸瀹為檯璁块棶鐨勫湴鍧�銆倂ue浼氶�氳繃浠g悊鏈嶅姟鍣ㄦ潵浠g悊璇锋眰
           changeOrigin: true,
-          ws: true,  // 鍏佽websocket浠g悊
-          rewrite: (path) => path.replace(/^\/api/, '') // 灏哸pi鏇挎崲涓虹┖
+          ws: false,  // 鍏佽websocket浠g悊
+          secure: false,
+          rewrite: (path) => path.replace(env.VITE_BASE_PATH, '/')
         }
       }
     }

--
Gitblit v1.9.3