9c620b32e2
서버 checkout에는 node_modules가 없어 npm run build만 실행하면 tsc를 찾지 못함. build-frontend.sh로 npm ci 후 workspace 빌드를 수행하고, frontend build 스크립트는 npx tsc/vite build로 통일. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/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"
|