import { fileURLToPath, URL } from "node:url"; import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; /** * 开发:Vite 跑在 127.0.0.1:5173,把 /api 代理到后端 127.0.0.1:8009,网页版同源、cookie 直接可用。 * 构建:资源基础路径默认 "/";桌面外壳(file:// 或自定义协议)构建时设 VITE_BASE=./, * 同时在 public/config.js 里把 routerMode 改成 "hash"(架构 §5.2 第 6 条)。 */ export default defineConfig({ base: process.env.VITE_BASE ?? "/", plugins: [vue()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)), // 设计规范是唯一的样式来源:tokens.css、components.css、logo 直接从 docs/design 引用,不复制 "@design": fileURLToPath(new URL("../../docs/design", import.meta.url)), }, }, server: { host: "127.0.0.1", port: 5173, strictPort: true, proxy: { "/api": { target: "http://127.0.0.1:8009", changeOrigin: false }, }, }, preview: { host: "127.0.0.1", port: 4173 }, });