Skip to content

Commit 9d9fc88

Browse files
committed
2 parents 73e477c + b62991e commit 9d9fc88

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

examples/app-host/.npmrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/app-host/scripts/build-vercel.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,33 @@ set -euo pipefail
77
# - api/[[...route]].js is committed to the repo (Vercel detects it pre-build)
88
# - esbuild bundles server/index.ts → api/_handler.js (self-contained bundle)
99
# - The committed .js wrapper re-exports from _handler.js at runtime
10+
# - Studio SPA is built and copied to public/ for serving the UI
1011
#
1112
# Steps:
12-
# 1. Build the project with turbo
13+
# 1. Build the project with turbo (includes studio)
1314
# 2. Bundle the API serverless function (→ api/_handler.js)
14-
# 3. Copy native/external modules into local node_modules for Vercel packaging
15+
# 3. Copy studio dist files to public/ for UI serving
1516

1617
echo "[build-vercel] Starting app-host build..."
1718

1819
# 1. Build the project with turbo (from monorepo root)
20+
# This builds both app-host and studio
1921
cd ../..
20-
pnpm turbo run build --filter=@example/app-host
22+
pnpm turbo run build --filter=@example/app-host --filter=@objectstack/studio
2123
cd examples/app-host
2224

2325
# 2. Bundle API serverless function
2426
node scripts/bundle-api.mjs
2527

26-
echo "[build-vercel] Done. Serverless function in api/[[...route]].js → api/_handler.js"
28+
# 3. Copy studio dist files to public/ for UI serving
29+
echo "[build-vercel] Copying studio dist to public/..."
30+
rm -rf public
31+
mkdir -p public
32+
if [ -d "../../apps/studio/dist" ]; then
33+
cp -r ../../apps/studio/dist/* public/
34+
echo "[build-vercel] ✓ Copied studio dist to public/"
35+
else
36+
echo "[build-vercel] ⚠ Studio dist not found (skipped)"
37+
fi
38+
39+
echo "[build-vercel] Done. Static files in public/, serverless function in api/[[...route]].js → api/_handler.js"

examples/app-host/vercel.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
"maxDuration": 60
1010
}
1111
},
12+
"headers": [
13+
{
14+
"source": "/assets/(.*)",
15+
"headers": [
16+
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
17+
]
18+
}
19+
],
1220
"rewrites": [
13-
{ "source": "/api/:path*", "destination": "/api/[[...route]]" }
21+
{ "source": "/api/:path*", "destination": "/api/[[...route]]" },
22+
{ "source": "/((?!api/).*)", "destination": "/index.html" }
1423
]
1524
}

0 commit comments

Comments
 (0)