From 034d87da6d10163fe7935253705ea42f8b06dd14 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Thu, 28 May 2026 22:40:58 +0900 Subject: [PATCH] fix(cloudflare): relocate wrangler.jsonc into apps/registry/ The ask-docs Cloudflare Pages build was failing with: Error: Output directory "apps/registry/dist" not found. Root cause: Pages auto-discovers wrangler config from the Root directory. Because ask-docs pointed its Root at the repo root, it picked up the registry-specific wrangler.jsonc (pages_build_output_dir: apps/registry/dist) and looked for output the docs build never produces. Fix: move wrangler.jsonc from the repo root into apps/registry/ so each Pages project has its own wrangler config next to its own source. Adjust pages_build_output_dir from apps/registry/dist to dist (now relative to apps/registry/) and the $schema path accordingly. Drop --config ../../wrangler.jsonc from the preview:cf script since wrangler auto-detects the config in the same folder. Requires paired Cloudflare Pages dashboard changes (see PR body): - ask-registry: Root directory / -> apps/registry, build output dist - ask-docs: Root directory / -> apps/docs --- apps/registry/package.json | 2 +- .../registry/wrangler.jsonc | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) rename wrangler.jsonc => apps/registry/wrangler.jsonc (58%) diff --git a/apps/registry/package.json b/apps/registry/package.json index 0dfc29b..01a7ffb 100644 --- a/apps/registry/package.json +++ b/apps/registry/package.json @@ -7,7 +7,7 @@ "build:node": "nuxt build", "dev": "nuxt dev", "preview": "nuxt preview", - "preview:cf": "wrangler pages dev --config ../../wrangler.jsonc", + "preview:cf": "wrangler pages dev", "lint": "eslint", "lint:fix": "eslint --fix", "test": "vitest run", diff --git a/wrangler.jsonc b/apps/registry/wrangler.jsonc similarity index 58% rename from wrangler.jsonc rename to apps/registry/wrangler.jsonc index 5910bd2..02d97f7 100644 --- a/wrangler.jsonc +++ b/apps/registry/wrangler.jsonc @@ -2,9 +2,10 @@ // // This file serves two purposes: // -// 1. `wrangler pages dev` (local preview, via `bun run --cwd apps/registry preview:cf`) reads it to -// mount the D1 binding `DB` against the real Cloudflare database -// used by production. That is the only way to exercise the +// 1. `wrangler pages dev` (local preview, via +// `bun run --cwd apps/registry preview:cf`) reads it to mount the D1 +// binding `DB` against the real Cloudflare database used by +// production. That is the only way to exercise the // `content.database = { type: 'd1', bindingName: 'DB' }` branch of // `nuxt.config.ts` on a developer machine. // @@ -19,18 +20,24 @@ // and prevents a silent regression if the dashboard binding is ever // removed. // +// Cloudflare Pages project setup (must match this file): +// - Root directory: apps/registry +// - Build command: cd ../.. && bun install && bun run build -- --filter=@pleaseai/ask-registry +// (turbo's `^build` dep makes schema build first) +// - Build output dir: dist (resolved under Root directory) +// // Note: Cloudflare Pages also accepts bindings configured through the // dashboard UI. The values here should match what the dashboard sets so // both entry points agree. { - "$schema": "apps/registry/node_modules/wrangler/config-schema.json", + "$schema": "node_modules/wrangler/config-schema.json", "name": "ask-registry", "compatibility_date": "2026-04-03", - // Nitro's `cloudflare_pages` preset emits registry assets to - // `apps/registry/dist/`. Cloudflare Pages runs with the repo root as - // its Root directory so turbo can build the schema workspace dep - // before Nuxt; the output path is relative to that root. - "pages_build_output_dir": "apps/registry/dist", + // Resolved relative to the Cloudflare Pages "Root directory" setting, + // which must be `apps/registry`. Nitro's `cloudflare_pages` preset + // emits the registry assets to `apps/registry/dist/`, i.e. `dist/` from + // this file's perspective. + "pages_build_output_dir": "dist", "d1_databases": [ { "binding": "DB",