Skip to content

feat: Cloudflare monorepo + vinext migration#668

Draft
codercatdev wants to merge 8 commits intodevfrom
feat/cloudflare-monorepo
Draft

feat: Cloudflare monorepo + vinext migration#668
codercatdev wants to merge 8 commits intodevfrom
feat/cloudflare-monorepo

Conversation

@codercatdev
Copy link
Contributor

Cloudflare Monorepo + Vinext Migration

Migrates the CodingCat.dev site from a single Next.js app on Vercel to a pnpm workspace monorepo deployed to Cloudflare Workers via vinext.

Changes

Phase A: pnpm Workspace Restructure

  • 378 files moved via git mv with 100% rename detection (full history preserved)
  • New structure: apps/web/ (Next.js site), apps/studio/ (Sanity Studio), packages/shared/ (schemas + API config)
  • Package names: @codingcatdev/web, @codingcatdev/studio, @codingcatdev/shared
  • Root pnpm-workspace.yaml with workspace scripts
  • Re-export shim at apps/web/sanity/lib/api.ts keeps 14 existing imports working
  • All 24 studio @/ imports rewritten to @codingcatdev/shared/... or relative paths

Phase B: Sanity Studio Extraction

  • apps/studio/ is now a standalone Sanity Studio app with its own package.json
  • Deployable independently via sanity deploy
  • Removed embedded studio route (app/(sanity)/studio/[[...tool]]/) from web app
  • Fixed packages/shared exports for .tsx files (settings.tsx)

Phase C: Vinext Migration

  • vinext check: 92% compatible (23 supported, 2 partial, 1 auto-fixed)
  • Replaced next commands with vinext in scripts (dev, build, start, deploy)
  • Added "type": "module" to package.json, renamed postcss.config.js.cjs
  • Created vite.config.ts with vinext + @vitejs/plugin-rsc + @cloudflare/vite-plugin
  • Created wrangler.jsonc for Cloudflare Workers deployment
  • next.config.ts preserved (vinext reads it for images, serverExternalPackages)
  • No application code modified — all next/* imports shimmed by vinext automatically
  • Removed @vercel/speed-insights (unused). Kept @vercel/analytics (client-side, compatible)

Key Technical Decisions

Decision Rationale
Re-export shims over mass import rewrites Minimizes blast radius — 3-line shim vs rewriting 14 files
@codingcatdev/shared with wildcard exports Both web and studio import schemas/lib from one source of truth
Keep next.config.ts vinext reads it for images config, serverExternalPackages, etc.
Keep @remotion/lambda in deps Only used in CLI/server files, being replaced by FFmpeg in content-engine
Keep react-instantsearch-nextjs Works for now; can fall back to base react-instantsearch if build issues

Validated: next-sanity Compatibility ✅

Deep-dived sanity-io/next-sanity source code. defineLive uses only:

  • draftMode() from next/headers — vinext supports
  • fetch with next.tags/next.revalidate — vinext supports ISR
  • Browser EventSource for real-time — pure browser API
  • preconnect/prefetchDNS from react-dom — standard React

The Live Content API (homepage's core feature) should work on vinext.

Known Risks / Follow-ups

  • react-instantsearch-nextjs — may need swap to base react-instantsearch if build fails
  • nextjs-toploader — uses Next.js router events, may need removal
  • @remotion/lambda — may need ssr.external in vite config if bundling issues
  • Rename NEXT_PUBLIC_SANITY_* env vars in studio (no longer Next.js)
  • Configure presentationTool.previewUrl for standalone studio deployment
  • Run pnpm approve-builds for workerd native binary
  • Full build test (vinext build) to validate end-to-end

Testing

  • vinext dev starts without errors
  • Homepage loads with live Sanity content
  • Algolia search works
  • Draft mode / Visual Editing works
  • vinext build completes
  • vinext deploy to Cloudflare Workers succeeds

Miriad and others added 6 commits March 13, 2026 19:05
V5b showed 2/4 infographic frames with gray/off-white backgrounds despite
the color rule saying 'Use ONLY black'. Restructured as numbered rules
with explicit rejection language. Background rule is now #1 priority.
Task 1D: engineConfig singleton + mediaAsset + automatedVideo v2 (PR #665, 6ab3833). Task 1E: Review dashboard with fail-closed auth on all server actions (PR #666, 18dee75). All code reviewed by @pm + workers.
- apps/web: Next.js site (all existing app code)
- apps/studio: Sanity Studio (standalone deploy target)
- packages/shared: Shared Sanity schemas + config

No import changes yet — structural move only.
- Create apps/web/sanity/lib/api.ts re-export shim so existing
  @/sanity/lib/api imports continue to work (delegates to @codingcatdev/shared)
- Fix all apps/studio/sanity.config.ts imports:
  - Schema imports → @codingcatdev/shared/sanity/schemas/...
  - Local plugins/components → relative paths (./sanity/...)
  - api.ts → @codingcatdev/shared/sanity/lib/api
- Fix assist.ts relative import to use @codingcatdev/shared
- Fix SharePreviewActionButton.tsx api import
- Fix YouTubePreview.tsx utils import (create local studio utils)
- Copy resolveHref.ts to studio (simple, no external deps)

Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
…Phase C)

Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
@vercel
Copy link

vercel bot commented Mar 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
codingcat-dev Ignored Ignored Mar 16, 2026 3:49pm

@codercatdev codercatdev changed the base branch from main to dev March 14, 2026 15:37
Miriad and others added 2 commits March 14, 2026 15:42
B1: Remove @vercel/speed-insights import and <SpeedInsights /> JSX from analytics.tsx
I1: Make studioUrl configurable via NEXT_PUBLIC_SANITY_STUDIO_URL env var
I2: Use SANITY_STUDIO_PREVIEW_URL for cross-origin presentationTool previewUrl
I3: Prefer SANITY_STUDIO_ env vars in sanity.cli.ts with NEXT_PUBLIC_ fallback
I5: Remove apps/web/vercel.json (no longer deploying to Vercel)

Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
- Deleted the @codingcatdev/shared package, consolidating Sanity schemas and API configurations directly within the apps.
- Updated imports in the studio and web apps to use local paths instead of the shared package.
- Removed the GEMINI.md file as it is no longer needed.
- Adjusted pnpm workspace configuration to reflect the removal of the shared package.

Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant