Deployment — Cloudflare (docs site)
The only deploy target at v0.1.0. A VitePress static site built from docs/ and shipped as a Cloudflare Worker with Static Assets via the Workers Builds flow (the unified successor to classic Cloudflare Pages).
All doc-related config lives inside docs/ — nothing docs-specific is placed at the repo root. Cloudflare's project root is set to docs/.
Pipeline
- Push to
main(or open a PR — Cloudflare creates a preview URL per branch). - Cloudflare Builds picks up the commit and
cds into the configured root directory (docs/). - Install:
npm install— readsdocs/package.json. - Build:
npm run build→vitepress build, writes static output todocs/.vitepress/dist/. - Deploy:
npx wrangler deployreadsdocs/wrangler.jsoncand uploads.vitepress/dist/as the Worker's static assets. - Cloudflare serves the assets on the
*.workers.devsubdomain (and any custom domain attached to the Worker).
Config
All of these live inside docs/:
docs/package.json— pinsvitepressand definesdev/build/previewscripts.docs/.vitepress/config.mts— site title, nav, sidebar, edit links, search.docs/wrangler.jsonc— Worker name, compatibility date, andassets.directorypointing at./.vitepress/dist. Without this filenpx wrangler deployhas nothing to deploy.docs/.nvmrc— pins the Node major version. Without it the builder may pick a Node older than VitePress 1.x supports.docs/.gitignore— keepsnode_modules/,.vitepress/dist/, and.vitepress/cache/out of git.
wrangler.jsonc — the assets-only Worker
jsonc
{
"name": "lavender-2-docs",
"compatibility_date": "2025-03-01",
"assets": {
"directory": "./.vitepress/dist",
"not_found_handling": "404-page",
"html_handling": "auto-trailing-slash"
}
}- No
main/ no fetch handler. Withassetsand nothing else, Cloudflare serves the directory as pure static content; no JavaScript runs at the edge. not_found_handling: "404-page"— serves the VitePress-built404.htmlfor any unknown path.html_handling: "auto-trailing-slash"— matches VitePress'scleanUrls: trueso/training/v0and/training/v0/both resolve totraining/v0.html.
One-time setup (repo owner)
- https://dash.cloudflare.com/ → Workers & Pages → Create → Import a repository (Workers Builds).
- Pick the
Lavender-2repository. - Configure the build:
- Production branch:
main - Root directory:
docs - Build command:
npm run build - Deploy command:
npx wrangler deploy - Build output directory (if asked):
.vitepress/dist
- Production branch:
- Environment variables (optional):
NODE_VERSION=22— belt-and-braces complement todocs/.nvmrc.
- Save and Deploy. The first deploy takes a minute or two; subsequent pushes to
mainauto-deploy and non-mainpushes get a preview URL on the Worker.
Local preview
bash
cd docs
npm install
npm run dev # live-reload dev server on http://localhost:5173Production build + preview:
bash
cd docs
npm run build
npm run previewManual deploy (requires wrangler login):
bash
cd docs
npm run build
npx wrangler deployPitfalls
- Do not move config files up to the repo root. The deployment contract is that
docs/is a self-contained VitePress + Wrangler project. Anything at the root confuses both Cloudflare's root- directory setting and readers looking for the docs source of truth. - If the build step succeeds but
npx wrangler deployerrors, checkdocs/wrangler.jsoncfirst. The failure mode looks like a successful VitePress build followed by wrangler running with nothing to deploy — that means either the config is missing orassets.directorydoesn't match the VitePress output path. - Node version matters. VitePress 1.x requires Node 18+; the Cloudflare Builds default may be older.
docs/.nvmrchandles this, but if you override it locally keep it ≥ 18. - Do not commit
docs/node_modules/ordocs/.vitepress/dist/.docs/.gitignorealready covers both; keep it. - VitePress
cleanUrls: truemeans internal links should not include a.htmlsuffix. Markdown.mdlinks work as-is. - Dead-link checking is loose by default (
ignoreDeadLinks: truein the config) because several in-page links reference GitHub blobs by line number. Flip that flag locally before shipping if you want a stricter check.