From 9c620b32e2c504f83dbcaecd8e87b501c78277c8 Mon Sep 17 00:00:00 2001 From: Macbook Date: Tue, 2 Jun 2026 23:14:16 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=84=9C=EB=B2=84=20work-tree=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=94=84=EB=A1=A0=ED=8A=B8=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8(tsc=20=EC=97=86=EC=9D=8C)=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 서버 checkout에는 node_modules가 없어 npm run build만 실행하면 tsc를 찾지 못함. build-frontend.sh로 npm ci 후 workspace 빌드를 수행하고, frontend build 스크립트는 npx tsc/vite build로 통일. Co-authored-by: Cursor --- frontend/package.json | 2 +- package.json | 1 + scripts/build-frontend.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 scripts/build-frontend.sh diff --git a/frontend/package.json b/frontend/package.json index 5e98799..62d9e2c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "npx tsc && npx vite build", "preview": "vite preview" }, "dependencies": { diff --git a/package.json b/package.json index 6b895a9..2f2653b 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "frontend" ], "scripts": { + "build:frontend": "npm run build -w react-trading-chart", "dev:app": "npm run dev -w @goldenchart/app", "build:app": "npm run build -w @goldenchart/app", "cap:sync": "npm run cap:sync -w @goldenchart/app", diff --git a/scripts/build-frontend.sh b/scripts/build-frontend.sh new file mode 100755 index 0000000..a66e7d1 --- /dev/null +++ b/scripts/build-frontend.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# 프론트엔드 프로덕션 빌드 (서버 work-tree / 로컬 공통) +# deploy.sh 는 Docker 로 빌드하므로 호스트에서 npm run build 할 때 이 스크립트를 사용한다. +set -euo pipefail + +export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:${PATH:-/usr/bin:/bin}" + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +FRONTEND="$ROOT/frontend" + +if ! command -v npm >/dev/null 2>&1; then + echo "[build-frontend] ERROR: npm 없음. PATH에 Node/npm을 추가하세요." >&2 + exit 127 +fi + +echo "[build-frontend] node=$(node -v) npm=$(npm -v)" +echo "[build-frontend] ROOT=$ROOT" + +# npm workspaces 모노레포: 루트에서 ci 후 workspace 빌드 +if [ -f "$ROOT/package.json" ] && grep -q '"workspaces"' "$ROOT/package.json" 2>/dev/null; then + if [ ! -d "$ROOT/node_modules" ]; then + echo "[build-frontend] npm ci (repo root)..." + (cd "$ROOT" && npm ci) + fi + echo "[build-frontend] npm run build -w react-trading-chart" + cd "$ROOT" && npm run build -w react-trading-chart +else + if [ ! -d "$FRONTEND/node_modules" ]; then + echo "[build-frontend] npm ci (frontend)..." + (cd "$FRONTEND" && npm ci) + fi + echo "[build-frontend] npm run build (frontend)" + cd "$FRONTEND" && npm run build +fi + +echo "[build-frontend] 완료 → $FRONTEND/dist"