Files
nexus-terminal/packages/frontend/vite.config.ts
T
yinjianm 96d9950c6b feat(frontend): 重构本地调试代理配置
将 `packages/frontend` 的 Vite 开发代理改为可通过环境变量
切换目标地址,并补充本地联调所需的默认主题与样式更新。
同时同步更新前后端默认 UI 主题定义,便于在本地直接验证
远端接口、WebSocket 与视觉效果。
2026-04-21 05:15:18 +08:00

42 lines
1.1 KiB
TypeScript

import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
import tailwindcss from '@tailwindcss/vite'
const frontendRoot = dirname(fileURLToPath(import.meta.url));
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, frontendRoot, '');
const proxyTarget = env.VITE_DEV_PROXY_TARGET || 'http://localhost:3001';
const wsProxyTarget = env.VITE_DEV_WS_PROXY_TARGET || 'ws://localhost:3001';
return {
plugins: [
vue(),
tailwindcss(),
// @ts-ignore because the plugin type might not perfectly match Vite's expected PluginOption type
(monacoEditorPlugin as any).default({})
],
server: {
proxy: {
'/api': {
target: proxyTarget,
changeOrigin: true,
},
'/uploads': {
target: proxyTarget,
changeOrigin: true,
},
'/ws': {
target: wsProxyTarget,
ws: true,
changeOrigin: true,
}
}
}
};
});