# `npx @sanity/cli functions build`

Build local Functions into zip archives. This command is hidden from generated help; use it when archive artifacts are explicitly needed, not as a required step before `blueprints deploy`.

## Build

Build every local Function in the Blueprint:

```sh
npx @sanity/cli functions build --json
```

Build one Function into a chosen directory:

```sh
npx @sanity/cli functions build process-order --out-dir artifacts/functions --json
```

Without `--out-dir`, archives are written to `.build/` beside the Blueprint manifest. An existing archive with the same Function name is replaced.

The JSON result contains `built`, `errors`, and `outDir`. A run can succeed when some Functions build and others fail, so inspect `errors` even when the exit code is zero. If every build fails, the command exits with an error.

The `.gitignore` written by `blueprints init` covers `functions/**/.build/`, not the top-level `.build/` these archives land in, so exclude the output directory before committing.
