Files
Aislo/vite.config.ts
T
eomsangdonandClaude Sonnet 5.5 e8f3cb8a9d fix(639-1): 낡은 시험 둘 고침 · vite 지켜보기에서 코드 아닌 폴더 제외
- test_551_2: 선 그리기 색 읽는 자리 = A00_Common/map/map_route_preview.ts (636-2 가 RecPreview 에서 옮김)
- test_624_2: D03 도구줄에 추천(recommend) 묶음 더해짐(636-2)
- vite.config.ts: server.watch.ignored = tmp · storage · docs · venv · logs · resources/tester · *.log

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-01 12:49:12 +09:00

81 lines
3.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
// ⚠ `localhost` 로 두지 말 것 — Node 18+ 는 그것을 **IPv6(::1) 먼저** 물고, 백엔드는
// `SERVER_HOST=0.0.0.0`(IPv4 전용)로 뜬다. 그러면 프록시가 `[::1]:<포트>` 로 붙으려다
// 실패해 화면의 **모든 `/api` 요청이 「Failed to fetch」** 가 된다 — 서버는 멀쩡한데
// 저장이 실패하고, 부팅 때 죽으면 화면이 통째로 백지가 된다(2026-09-07 실측:
// `127.0.0.1:8001` 200 · `[::1]:8001` 연결 실패). 숫자로 박아 그 갈림을 없앤다.
const apiTarget = `http://127.0.0.1:${process.env.AISLO_API_PORT ?? "8000"}`;
const devPort = Number(process.env.FRONTEND_DEV_PORT ?? 5173);
/**
* 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"),
delaunator: resolve(__dirname, "./config/node_modules/delaunator"),
"@kninnug/constrainautor": resolve(
__dirname,
"./config/node_modules/@kninnug/constrainautor",
),
},
},
server: {
// main.py가 CLI --port로 덮지만, `npm run dev` 맨손 실행에서 보조 워크트리가
// 메인의 5173을 뺏지 않도록 env를 먼저 본다(dev_up.py가 주입한다).
port: devPort,
open: false,
// 코드가 아닌 폴더(서버 로그 · 자료 · 문서 · 파이썬 환경)의 파일 바뀜은 지켜보지 않음 —
// 화면이 저절로 새로 읽히는 일을 막는다(639-1). 코드(.ts · .css)는 그대로 지켜봄.
watch: {
ignored: ["tmp", "storage", "docs", "venv", "logs", "resources/tester"]
.map((dir) => `${__dirname.replace(/\\/g, "/")}${dir}/**`)
.concat(["**/*.log", "**/__pycache__/**"]),
},
// 백엔드(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,
},
},
},
// 빌드판(555-2 · `tools/preview_up.py`) — 폰 · 외부 접속용 · 포트 = 개발 포트 − 1000(5173 → 4173)
// · 프록시(/api · /b07-cad)는 server.proxy 를 그대로 물려받음.
preview: {
port: devPort - 1000,
strictPort: true,
host: true,
},
build: {
outDir: "../config/node_modules/.build",
emptyOutDir: true,
target: "es2022",
},
optimizeDeps: {
exclude: ["0_old"],
},
};