StaticSite
Source:
src/Cloudflare/Website/StaticSite.ts
A Cloudflare Worker that serves static assets built by a shell command.
StaticSite runs a build command (e.g. npm run build), content-hashes
the output directory, and deploys the result as a Cloudflare Worker with
static assets. Use this when your site has its own build step that
produces a directory of files — Hugo, Zola, Eleventy, or any custom
pipeline.
For Vite-based projects, prefer Cloudflare.Vite which handles
building automatically.
Basic Usage
Section titled “Basic Usage”Point command at your build script and outdir at where it writes
output. Alchemy runs the command, hashes the output, and deploys it.
const site = yield* Cloudflare.StaticSite("Blog", { command: "hugo --minify", outdir: "public",});Asset Configuration
Section titled “Asset Configuration”Use assetsConfig to control how Cloudflare handles routing for
your static files — HTML handling, not-found behavior, etc.
const site = yield* Cloudflare.StaticSite("App", { command: "npm run build", outdir: "dist", assetsConfig: { htmlHandling: "auto-trailing-slash", notFoundHandling: "single-page-application", },});Custom Rebuild Scope
Section titled “Custom Rebuild Scope”By default, all non-gitignored files are hashed to decide whether
the build should re-run. Use memo to narrow the scope.
const site = yield* Cloudflare.StaticSite("Docs", { command: "npm run build", outdir: "dist", memo: { include: ["content/**", "templates/**", "config.toml"], },});