import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; const __dirname = fileURLToPath(new URL(".", import.meta.url)); const apiTarget = `http://localhost:${process.env.AISLO_API_PORT ?? "8000"}`; /** * Vite 설정 — 임도 설계 웹앱 (Vanilla TS + Three.js) * * - root: A00_Common (index.html 위치) * - 페이지 폴더(A01_Home 등)는 ../를 통해 접근 * - 0_old(구형 코드), venv(파이썬)는 빌드에서 제외 */ export default { root: "A00_Common", publicDir: false, cacheDir: "config/node_modules/.vite", resolve: { alias: { "@ui": resolve(__dirname, "./ui_template"), "@config": resolve(__dirname, "./config"), "@util": resolve(__dirname, "./common_util"), three: resolve(__dirname, "./config/node_modules/three"), "maplibre-gl": resolve(__dirname, "./config/node_modules/maplibre-gl"), }, }, server: { // main.py가 CLI --port로 덮지만, `npm run dev` 맨손 실행에서 보조 워크트리가 // 메인의 5173을 뺏지 않도록 env를 먼저 본다(dev_up.py가 주입한다). port: Number(process.env.FRONTEND_DEV_PORT ?? 5173), open: false, // 백엔드(FastAPI) 프록시 — config_frontend.ts의 API_BASE_URL과 정합. // 포트는 AISLO_API_PORT로 바꿀 수 있다(기본 8000) — 워크트리를 나눠 쓰는 병행 // 작업에서 각자 자기 백엔드를 보게 하려는 것이다(2026-08-30, CLAUDE.md 7장). proxy: { "/api": { target: apiTarget, changeOrigin: true, }, // B07 독립형 CAD 앱 — FastAPI 정적 마운트로 위임 "/b07-cad": { target: apiTarget, changeOrigin: true, }, }, }, build: { outDir: "../config/node_modules/.build", emptyOutDir: true, target: "es2022", }, optimizeDeps: { exclude: ["0_old"], }, };