anvil build to compile your Anvil project for production. The command does two things in sequence: it runs the compiler to scan your routes and emit a typed manifest, then it bundles a self-contained Node.js server. The output is a single ESM file you can run with node or hand off to anvil start.
Usage
Flags
string
default:"server/routes"
Directory Anvil scans for route files. Must match the layout expected by the manifest loader.
string
default:".gen"
Output directory for generated source files. Anvil writes
routes.ts and an intermediate server.ts entry point here before bundling.string
default:"dist/server.mjs"
Path for the final output bundle. The
.mjs extension signals that the file is an ES module.boolean
Stop after emitting
.gen/routes.ts. Skip generating server.ts and skip the bundling step entirely. Useful for CI validation and type-checking without producing a full build artifact.What the build produces
1
Scan routes and emit the manifest
Anvil walks your routes directory, validates each module’s param names and schemas, and writes a fully-typed
routes.ts to the generated sources directory. The console prints how many routes were discovered:2
Generate the server entry point
Anvil writes a minimal
.gen/server.ts that imports your manifest, calls createApp, and starts the HTTP server. This file is the bundle entry point — you don’t need to write or maintain it yourself:3
Bundle the server
Anvil compiles and bundles
server.ts targeting Node.js 20, ESM format, with source maps and all node_modules marked as external. The result lands at dist/server.mjs:Example: default build
Example: custom paths
Example: manifest-only (CI validation)
Use--manifest-only to validate route structure and schema serializability in a CI pipeline without spending time on the full bundle:
--manifest-only is ideal for a lightweight CI validation step. Run it alongside anvil lint to catch both structural errors and schema issues before deploying MCP tools.