iching-broker-level2/start-local.sh

39 lines
838 B
Bash
Raw Normal View History

2025-04-16 13:37:16 +00:00
# build
#npm install
#npx tsc -p tsconfig.backend.json
#npx tsc -p tsconfig.frontend.json
#npm run start:local
#!/bin/bash
# Exit on error
set -e
# 1. Install dependencies
npm install
# 2. Compile backend and frontend
npx tsc -p tsconfig.backend.json
npx tsc -p tsconfig.frontend.json
# 3. Ensure dist/frontend exists and copy index.html
mkdir -p dist/frontend
cp frontend/index.html dist/frontend/
2025-04-17 12:46:32 +00:00
mkdir -p dist/backend
cp backend/config.json dist/backend/
# 4. Rename compiled frontend event.js → event.mjs
find dist/frontend -name "event.js" -exec bash -c 'mv "$0" "${0%.js}.mjs"' {} \;
2025-04-16 13:37:16 +00:00
# 5. Inject deploy mode
echo "window.DEPLOY_MODE = 'local';" > dist/frontend/deploy.js
# 6. Start backend
node dist/backend/server.js &
# 7. Start frontend
npx http-server dist/frontend -p 8080 --cors --mime application/javascript=js