build(vite config): 优化开发服务器代理与端口配置
- 将开发服务器端口提取为常量 SERVER_PORT 以简化维护 - 为 API 代理添加环境注释并注释备用后端地址 - 新增本地测试用的 vimp/api 代理配置 - 新增 CDN 代理指向本地开发服务器端口
This commit is contained in:
+12
-2
@@ -4,6 +4,8 @@ import { fileURLToPath, URL } from 'node:url';
|
||||
import { defineConfig, ProxyOptions } from 'vite';
|
||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||
|
||||
const SERVER_PORT = 9763;
|
||||
|
||||
type ProxyItem = {
|
||||
key: string;
|
||||
target: string;
|
||||
@@ -198,7 +200,8 @@ const apiProxyList: ProxyItem[] = [
|
||||
...line04ApiProxyList,
|
||||
|
||||
{ key: '/minio', target: 'http://10.18.128.10:9000', rewrite: ['/minio', ''] },
|
||||
{ key: '/api', target: 'http://10.18.128.10:18760' },
|
||||
{ key: '/api', target: 'http://10.18.128.10:18760' }, // 吴中路控制中心
|
||||
// { key: '/api', target: 'http://10.18.187.10:18760' }, // 紫藤路
|
||||
{ key: '/ws', target: 'ws://10.18.128.10:18103', ws: true },
|
||||
...line10ApiProxyList,
|
||||
|
||||
@@ -207,6 +210,13 @@ const apiProxyList: ProxyItem[] = [
|
||||
// { key: '/api', target: 'http://10.24.0.10:18760' },
|
||||
// { key: '/ws', target: 'ws://10.24.0.10:18103', ws: true },
|
||||
...line21YangpuTestProxyList,
|
||||
|
||||
// 设备树测试用代理配置
|
||||
// { key: '/vimp/api', target: 'http://10.14.0.10:18080', rewrite: ['/vimp/api', '/api'] },
|
||||
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
||||
{ key: '/vimp/api', target: 'http://localhost:4000', rewrite: ['/vimp/api', '/api'] },
|
||||
// { key: '/vimp/api', target: 'http://10.18.128.6:18080', rewrite: ['/vimp/api', '/api'] },
|
||||
{ key: '/cdn', target: `http://localhost:${SERVER_PORT}`, rewrite: ['/cdn', ''] },
|
||||
];
|
||||
|
||||
// https://vite.dev/config/
|
||||
@@ -232,7 +242,7 @@ export default defineConfig((/* { command, mode } */) => {
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 9763,
|
||||
port: SERVER_PORT,
|
||||
proxy: viteProxy,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user