-
Notifications
You must be signed in to change notification settings - Fork 1
feat(app-host): serve Studio UI on homepage #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,20 +7,33 @@ set -euo pipefail | |||||||||||||||||||||||||||||||||||||||||||
| # - api/[[...route]].js is committed to the repo (Vercel detects it pre-build) | ||||||||||||||||||||||||||||||||||||||||||||
| # - esbuild bundles server/index.ts → api/_handler.js (self-contained bundle) | ||||||||||||||||||||||||||||||||||||||||||||
| # - The committed .js wrapper re-exports from _handler.js at runtime | ||||||||||||||||||||||||||||||||||||||||||||
| # - Studio SPA is built and copied to public/ for serving the UI | ||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||
| # Steps: | ||||||||||||||||||||||||||||||||||||||||||||
| # 1. Build the project with turbo | ||||||||||||||||||||||||||||||||||||||||||||
| # 1. Build the project with turbo (includes studio) | ||||||||||||||||||||||||||||||||||||||||||||
| # 2. Bundle the API serverless function (→ api/_handler.js) | ||||||||||||||||||||||||||||||||||||||||||||
| # 3. Copy native/external modules into local node_modules for Vercel packaging | ||||||||||||||||||||||||||||||||||||||||||||
| # 3. Copy studio dist files to public/ for UI serving | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| echo "[build-vercel] Starting app-host build..." | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # 1. Build the project with turbo (from monorepo root) | ||||||||||||||||||||||||||||||||||||||||||||
| # This builds both app-host and studio | ||||||||||||||||||||||||||||||||||||||||||||
| cd ../.. | ||||||||||||||||||||||||||||||||||||||||||||
| pnpm turbo run build --filter=@example/app-host | ||||||||||||||||||||||||||||||||||||||||||||
| pnpm turbo run build --filter=@example/app-host --filter=@objectstack/studio | ||||||||||||||||||||||||||||||||||||||||||||
| cd examples/app-host | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # 2. Bundle API serverless function | ||||||||||||||||||||||||||||||||||||||||||||
| node scripts/bundle-api.mjs | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| echo "[build-vercel] Done. Serverless function in api/[[...route]].js → api/_handler.js" | ||||||||||||||||||||||||||||||||||||||||||||
| # 3. Copy studio dist files to public/ for UI serving | ||||||||||||||||||||||||||||||||||||||||||||
| echo "[build-vercel] Copying studio dist to public/..." | ||||||||||||||||||||||||||||||||||||||||||||
| rm -rf public | ||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p public | ||||||||||||||||||||||||||||||||||||||||||||
| if [ -d "../../apps/studio/dist" ]; then | ||||||||||||||||||||||||||||||||||||||||||||
| cp -r ../../apps/studio/dist/* public/ | ||||||||||||||||||||||||||||||||||||||||||||
| echo "[build-vercel] ✓ Copied studio dist to public/" | ||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||
| echo "[build-vercel] ⚠ Studio dist not found (skipped)" | ||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+38
|
||||||||||||||||||||||||||||||||||||||||||||
| rm -rf public | |
| mkdir -p public | |
| if [ -d "../../apps/studio/dist" ]; then | |
| cp -r ../../apps/studio/dist/* public/ | |
| echo "[build-vercel] ✓ Copied studio dist to public/" | |
| else | |
| echo "[build-vercel] ⚠ Studio dist not found (skipped)" | |
| fi | |
| STUDIO_DIST="../../apps/studio/dist" | |
| PUBLIC_DIR="public" | |
| if [ ! -d "$STUDIO_DIST" ]; then | |
| echo "[build-vercel] ✗ Studio dist not found at $STUDIO_DIST" | |
| echo "[build-vercel] ✗ Failing build because the Studio UI bundle is required for deployment" | |
| exit 1 | |
| fi | |
| rm -rf "$PUBLIC_DIR" | |
| mkdir -p "$PUBLIC_DIR" | |
| cp -r "$STUDIO_DIST"/. "$PUBLIC_DIR"/ | |
| echo "[build-vercel] ✓ Copied studio dist to public/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Studio is built from app-host, no Vite env vars are set. Studio defaults to
mode: 'msw'(andserverUrl: 'http://localhost:3000') unlessVITE_RUNTIME_MODE=serverandVITE_SERVER_URLare provided or it’s served under/_studio. For a deployed homepage, this likely means the UI won’t connect to the app-host API by default. Consider exportingVITE_RUNTIME_MODE=serverand settingVITE_SERVER_URLto empty string (same-origin) for the Studio build in this script.