Spaces:
Running
Running
Commit
·
c8d8fd0
1
Parent(s):
df06d8a
Fix backend start path and automate all HF patches
Browse files- deploy.sh now patches backend package.json for esbuild output path
- deploy.sh now patches backend server.ts for frontend path
- All HF-specific patches are now automated in deploy.sh
Co-Authored-By: Claude <noreply@anthropic.com>
- deploy.sh +10 -0
- trigo-web/backend/package.json +2 -2
- trigo-web/backend/src/server.ts +0 -1
deploy.sh
CHANGED
|
@@ -143,6 +143,16 @@ sed -i '/^VITE_SERVER_URL=/d' .env 2>/dev/null || true
|
|
| 143 |
rm -f .env.local backend/.env.local 2>/dev/null || true
|
| 144 |
cd "$HF_SPACE"
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
echo ""
|
| 147 |
echo "✅ Files prepared and patched successfully!"
|
| 148 |
echo ""
|
|
|
|
| 143 |
rm -f .env.local backend/.env.local 2>/dev/null || true
|
| 144 |
cd "$HF_SPACE"
|
| 145 |
|
| 146 |
+
# Patch backend package.json for esbuild output location
|
| 147 |
+
echo " Patching backend package.json for esbuild output..."
|
| 148 |
+
cd "$HF_SPACE/trigo-web/backend"
|
| 149 |
+
sed -i 's|dist/backend/src/server.js|dist/server.js|g' package.json
|
| 150 |
+
cd "$HF_SPACE"
|
| 151 |
+
|
| 152 |
+
# Patch backend server.ts for esbuild frontend path
|
| 153 |
+
echo " Patching backend server.ts for frontend path..."
|
| 154 |
+
sed -i 's|"../../../../app/dist"|"../../app/dist"|' "$HF_SPACE/trigo-web/backend/src/server.ts"
|
| 155 |
+
|
| 156 |
echo ""
|
| 157 |
echo "✅ Files prepared and patched successfully!"
|
| 158 |
echo ""
|
trigo-web/backend/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
| 3 |
"version": "1.0.0",
|
| 4 |
"type": "module",
|
| 5 |
"description": "Backend server for Trigo game",
|
| 6 |
-
"main": "dist/
|
| 7 |
"scripts": {
|
| 8 |
"dev": "nodemon --watch src --exec tsx src/server.ts",
|
| 9 |
"build": "tsc",
|
| 10 |
-
"start": "node dist/
|
| 11 |
"test": "echo \"Error: no test specified\" && exit 1"
|
| 12 |
},
|
| 13 |
"keywords": [
|
|
|
|
| 3 |
"version": "1.0.0",
|
| 4 |
"type": "module",
|
| 5 |
"description": "Backend server for Trigo game",
|
| 6 |
+
"main": "dist/server.js",
|
| 7 |
"scripts": {
|
| 8 |
"dev": "nodemon --watch src --exec tsx src/server.ts",
|
| 9 |
"build": "tsc",
|
| 10 |
+
"start": "node dist/server.js",
|
| 11 |
"test": "echo \"Error: no test specified\" && exit 1"
|
| 12 |
},
|
| 13 |
"keywords": [
|
trigo-web/backend/src/server.ts
CHANGED
|
@@ -69,7 +69,6 @@ app.use(express.json());
|
|
| 69 |
|
| 70 |
// Serve static files from frontend build (for production)
|
| 71 |
if (process.env.NODE_ENV === "production") {
|
| 72 |
-
// With esbuild bundle at backend/dist/server.js, go up 2 levels then into app/dist
|
| 73 |
const frontendPath = path.join(__dirname, "../../app/dist");
|
| 74 |
app.use(express.static(frontendPath));
|
| 75 |
|
|
|
|
| 69 |
|
| 70 |
// Serve static files from frontend build (for production)
|
| 71 |
if (process.env.NODE_ENV === "production") {
|
|
|
|
| 72 |
const frontendPath = path.join(__dirname, "../../app/dist");
|
| 73 |
app.use(express.static(frontendPath));
|
| 74 |
|