Vocs
Source:
src/Cloudflare/Website/Vocs.ts
A Cloudflare Worker deployed from a Vocs documentation project.
Vocs’ vocs.config.* loads natively. Alchemy runs Vocs’ Waku/RSC build,
deploys its server environments as a Worker, and publishes the client and
prerendered output as static assets. No Vite or Wrangler config is required.
Requires @alchemy.run/frontend-frameworks, vocs, and Vocs’ Waku peer
dependencies in the project.
Input files are content-hashed (respecting .gitignore by default), so an
unchanged project skips its build and deployment. Vocs’ server runtime uses
Node APIs, so nodejs_compat is included in the Worker’s compatibility
flags automatically.
Deploying a Vocs Site
Section titled “Deploying a Vocs Site”A single resource builds the documentation project and deploys its server runtime, prerendered pages, generated files, and public assets.
const docs = yield* Cloudflare.Website.Vocs("Docs", { rootDir: "./docs",});Bindings
Section titled “Bindings”Pass Cloudflare resources through env like any other Worker. Server-side
Vocs and MDX code can access them from cloudflare:workers.
const searchCache = yield* Cloudflare.KV.Namespace("SearchCache");
const docs = yield* Cloudflare.Website.Vocs("Docs", { rootDir: "./docs", env: { SEARCH_CACHE: searchCache, },});Custom Build Output
Section titled “Custom Build Output”Vocs configuration continues to own the output directory. When
vocs.config.* changes outDir, mirror that value on the resource so the
generated directory is excluded from the rebuild hash and read correctly.
// vocs.config.ts: defineConfig({ outDir: "build" })const docs = yield* Cloudflare.Website.Vocs("Docs", { rootDir: "./docs", outDir: "build",});Custom Rebuild Scope
Section titled “Custom Rebuild Scope”Use memo to narrow the files that trigger a rebuild in large projects.
const docs = yield* Cloudflare.Website.Vocs("Docs", { rootDir: "./docs", memo: { include: ["src/**", "public/**", "vocs.config.ts", "package.json"], },});Class Form
Section titled “Class Form”Calling Vocs without arguments returns a constructor for declaring the
deployed Worker as a named class.
class Docs extends Cloudflare.Website.Vocs<Docs>()("Docs", { rootDir: "./docs",}) {}
const docs = yield* Docs;