StaticSite
Source:
src/Railway/Website/StaticSite.ts
A Railway Service 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 Node static-file
server on one Railway.Service. 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 Railway.Website.Vite which handles building automatically.
Cloudflare DX: top-level command + outdir (Command.BuildProps).
Only Command.Build("Build") / Command.Dev("Dev") are pushed under
the site id; the Service stays in the caller namespace.
During alchemy dev, dev.command skips the build and is the site.
Without dev.command, the site still builds and a local static server
serves outdir — no Project or Service is created.
Basic Usage
Section titled “Basic Usage”Deploying a Hugo site
const site = yield* Railway.Website.StaticSite("Blog", { command: "hugo --minify", outdir: "public",});SPA-style routing
const site = yield* Railway.Website.StaticSite("App", { command: "npm run build", outdir: "dist", spa: true,});Building from a Subdirectory
Section titled “Building from a Subdirectory”const site = yield* Railway.Website.StaticSite("Web", { cwd: "apps/web", command: "npm run build", outdir: "dist",});Local Development
Section titled “Local Development”const site = yield* Railway.Website.StaticSite("App", { command: "npm run build", outdir: "dist", dev: { command: "npm run dev" },});