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
Directory Anvil scans for route files. Must match the layout expected by the manifest loader.
Output directory for generated source files. Anvil writes
routes.ts and an intermediate server.ts entry point here before bundling.Path for the final output bundle. The
.mjs extension signals that the file is an ES module.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
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: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: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.