Skip to content

Build

Source: src/Command/Build.ts

A Build runs a shell command that produces an output asset (a file or directory) and tracks that asset in state. Unlike Exec, a Build has an output contract: reconcile verifies the command actually produced outdir and exposes its location so downstream resources (e.g. a Cloudflare.Worker’s static assets) can consume it.

Inputs are content-hashed by default so an unchanged project skips the rebuild entirely; set memo: false to rebuild on every deploy.

const build = yield* Build("vite-build", {
command: "npm run build",
cwd: "./frontend",
outdir: "dist",
});
yield* Console.log(build.outdir); // path to the dist directory, relative to process.cwd()
yield* Console.log(build.hash.output); // hash of the output files (when memo is enabled)
const build = yield* Build("production-build", {
command: "npm run build",
cwd: "./app",
outdir: "dist",
env: {
NODE_ENV: "production",
API_URL: "https://api.example.com",
},
});
const build = yield* Build("custom-build", {
command: "npm run build",
cwd: "./app",
outdir: "dist",
memo: { include: ["src/**", "package.json"], exclude: ["node_modules", "dist"] },
});