import { fileURLToPath, URL } from 'node:url' import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import tailwindcss from '@tailwindcss/vite' /** 开发代理保留 /api 前缀;长工作流不使用代理层的短超时。 */ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') return { plugins: [vue(), tailwindcss()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, server: { /** 监听所有网卡,使 Vite 启动时输出可访问的局域网 IP。 */ host: true, /** 允许 Work Mode 通过本地预览域名进行移动端视觉验收。 */ allowedHosts: ['terminal.local'], port: 4312, proxy: { '/api': { target: env.API_PROXY_TARGET || 'http://localhost:3412', changeOrigin: true, timeout: 0, proxyTimeout: 0 }, '/storage': { target: env.API_PROXY_TARGET || 'http://localhost:3412', changeOrigin: true } } } } })