File size: 1,171 Bytes
82a1419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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