-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-server.sh
More file actions
executable file
·36 lines (31 loc) · 836 Bytes
/
Copy pathstart-server.sh
File metadata and controls
executable file
·36 lines (31 loc) · 836 Bytes
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
set -euo pipefail
cd "$(dirname "$0")"
MODE="pages"
if [[ "${1:-}" == "--dev" || "${1:-}" == "-d" ]]; then
MODE="dev"
fi
# Install deps on first run.
if [[ ! -d node_modules ]]; then
echo "Installing dependencies..."
npm install
fi
free_port() {
local port="$1"
local pids
pids="$(lsof -ti:"$port" 2>/dev/null || true)"
if [[ -n "$pids" ]]; then
echo "Freeing port $port (killing: $pids)"
kill -9 $pids 2>/dev/null || true
fi
}
if [[ "$MODE" == "dev" ]]; then
free_port 5173
echo "Starting Vite dev server → http://localhost:5173 (no /api Functions)"
exec npm run dev -- --host --port 5173 --strictPort
else
free_port 8788
echo "Building..."
npm run build
echo "Starting Pages dev server → http://localhost:8788 (with /api Functions)"
exec npx wrangler pages dev ./dist --port 8788
fi