---
title: bapX build
description: Reference for creating deployable Bapx application artifacts.
lastReviewedAt: 2026-05-30
---

## Synopsis

```bash
bapX build [--target <node|cloudflare>] [--root <path>] [--output <path>] [--config <path>] [--env <path>]
```

## Description

`bapX build` discovers agents, workflows, and an optional application entrypoint under the selected source root, then writes target-specific deployment output.

For source discovery rules, see [Project Layout](/guide/project-layout/).

## Options

| Option                        | Default                                                    | Description                                                                                                                         |
| ----------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `--target <node\|cloudflare>` | Configuration value                                        | Select the build target. Required unless supplied by configuration.                                                                 |
| `--root <path>`               | Selected config-file directory, or config search directory | Select the project root.                                                                                                            |
| `--output <path>`             | `<root>/dist`                                              | Select the build output directory.                                                                                                  |
| `--config <path>`             | Auto-discovered `bapX.config.*`                            | Select a configuration file.                                                                                                        |
| `--env <path>`                | `<config-base>/.env`, when present                         | Select one alternate `.env`-format file loaded before configuration. Relative paths resolve from `<config-base>`. Shell values win. |

## Node.js output

A Node build writes a runnable server artifact:

```text
<output>/server.mjs
```

See [Deploy on Node.js](/ecosystem/deploy/node/) for runtime dependencies and deployment setup.

## Cloudflare output

A Cloudflare build writes a Workers-compatible application through the official Cloudflare Vite integration. Bapx prepares generated Worker and Wrangler input files without rewriting the project's authored Wrangler configuration. Durable Object migration history remains in the project-root Wrangler config and passes through unchanged.

See [Deploy on Cloudflare](/ecosystem/deploy/cloudflare/) for bindings and deployment setup.

## Examples

```bash
bapX build --target node
bapX build --target cloudflare --root ./my-app
bapX build --target node --output ./build
```
