Files
Aislo/vite.config.ts
T
eomsangdonandClaude Opus 5.5 a09ac1c42d feat(모바일): 불러오는 중 판 · 빌드판 서버 · CAD 글꼴 404 (PLAN 555)
- index.html — 첫 페이지 전까지 「불러오는 중」(테마 바탕 · 저장 테마 · 시스템 어두움) · 20 s 뒤 느린 연결 안내 · favicon 요청 없앰
- tools/preview_up.py — 앱 · CAD 빌드 뒤 vite preview(포트 = 개발 포트 − 1000 · /api · /b07-cad 프록시)
- CAD 빌드에 공용 글꼴 복사 — Tailwind 가 url 을 고치지 않아 dist/assets 에서 찾던 404
- 시험 test_555_boot_loader_preview.py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 06:56:26 +09:00

74 lines
2.9 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,
// 백엔드(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"],
},
};