1pnpm add -D wrangler @cloudflare/vite-plugin
vite.config.ts:123456789101112131415import { cloudflare } from '@cloudflare/vite-plugin' import { holocron } from '@holocron.so/vite' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ holocron(), cloudflare({ viteEnvironment: { name: 'rsc', childEnvironments: ['ssr'], }, }), ], })
wrangler.json or wrangler.jsonc:123456{ "name": "my-docs", "main": "spiceflow/cloudflare-entrypoint", "compatibility_date": "2026-04-13", "compatibility_flags": ["nodejs_compat"] }
12npx vite build npx wrangler deploy
routes. If production owns a
custom domain and preview should use workers.dev, preview must explicitly set
"routes": []. Omitting the property can reassign the production domain to the
preview Worker during wrangler deploy --env preview.123456789101112{ "name": "my-docs", "routes": [ { "pattern": "docs.example.com", "custom_domain": true } ], "env": { "preview": { "name": "my-docs-preview", "routes": [] } } }
CLOUDFLARE_ENV while Vite builds so the Cloudflare plugin flattens the
matching environment into dist/rsc/wrangler.json:123456{ "scripts": { "deploy": "CLOUDFLARE_ENV=preview vite build && wrangler deploy --env preview", "deploy:prod": "vite build && wrangler deploy" } }
12pnpm run deploy pnpm run deploy:prod
pnpm deploy is pnpm's built-in deployment command, not a reliable way to run
the package's "deploy" script. Treat Wrangler warnings about inherited routes
or custom-domain reassignment as deployment blockers.base in vite.config.ts to mount the whole site under a path prefix, for example when the docs live at example.com/docs behind a route:1234export default defineConfig({ base: '/docs', plugins: [holocron(), cloudflare({ /* ... */ })], })
/docs/assets/app.js from dist/client/docs/assets/app.js:vite.config.ts build output request ┌───────────────────┐ ┌───────────────────────────┐ ┌────────────────────────┐ │ base: '/docs' │───────>│ dist/client/ │ │ GET /docs/assets/app.js│ │ │ │ .assetsignore │ └───────────┬────────────┘ │ HTML references │ │ docs/assets/app.js <───┼───────────────────┘ │ /docs/assets/* │ │ docs/icons/logo.svg │ served by the CDN, └───────────────────┘ └───────────────────────────┘ no Worker invocation
example-cloudflare/ directory in the Holocron repo for a minimal Cloudflare Workers deployment.base, so this nesting is what makes subpath hosting work. It happens automatically; no ASSETS binding or extra config needed.