38 lines
838 B
Bash
Executable file
38 lines
838 B
Bash
Executable file
|
|
# 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/
|
|
|
|
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"' {} \;
|
|
|
|
# 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
|