#!/bin/bash # Run backend + frontend build watcher so frontend auto-rebuilds on change (no manual npm run build). set -e cd "$(dirname "$0")" if [ ! -d "venv" ]; then echo "❌ venv not found. Run: bash setup.sh" exit 1 fi source venv/bin/activate # Build frontend once, then start watcher in background echo "📦 Building frontend once..." (cd frontend && npm run build) echo "👀 Starting frontend build watcher (rebuilds on file change)..." (cd frontend && npm run build:watch) & WATCHER_PID=$! trap "kill $WATCHER_PID 2>/dev/null" EXIT # Wait for dist/assets so Python doesn't start while watcher cleared the dir echo "⏳ Waiting for frontend build to be ready..." i=0 while [ $i -lt 30 ]; do if [ -d "frontend/dist/assets" ] && [ -n "$(ls frontend/dist/assets 2>/dev/null)" ]; then break fi sleep 1 i=$((i + 1)) done if [ ! -d "frontend/dist/assets" ] || [ -z "$(ls frontend/dist/assets 2>/dev/null)" ]; then echo "❌ frontend/dist/assets not ready after 30s. Check frontend build." exit 1 fi echo "🚀 Starting backend at http://localhost:4000" echo " Edit frontend files → auto-rebuild → refresh browser" echo "" python main.py