# Azion CLI build

The Azion CLI `build` command builds the project in the current directory on your machine and writes the result to the `.edge` folder. It runs the Azion Bundler with the project's preset and generates `.edge/manifest.json`, the file a local deploy reads. The command does not deploy anything. The options every command accepts, such as `--format`, `--out`, and `-y`, are on [Global options](/en/documentation/devtools/cli/globals/).

---

## Usage

`azion build` reads the project settings from the `azion` folder of the current directory. Run it in the root folder of the project:

```bash
azion build [flags]
```

| Flag                     | Short | Type   | Default     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------ | ----- | ------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--alias-env`            | —     | —      | —           | Renames each variable that the build reads from the project's `.env` files with a prefix built from the project's name, both in the bundle and in `.edge/.env.azion`. The prefix is the name in uppercase, with each run of characters other than letters and digits turned into one `_`, plus a final `_`: `my-app` gives `MY_APP_`.                                                                                                                                     |
| `--config-dir`           | —     | string | `"azion"`   | Relative path to the folder that holds your `azion.json` and `args.json` files.                                                                                                                                                                                                                                                                                                                                                                                           |
| `--config-file`          | —     | string | —           | Path to the `azion.config` file to build with, such as `azion.staging.config.cjs`. Without it, the build uses the `azion.config.*` file in the current directory. A relative path resolves from the current directory. With `--debug`, the output names the file in use: `Using azion.staging.config.cjs config file`. A path to a missing file fails with `Error: The azion.config file informed in --config-file was not found. Verify the path and try again: <path>`. |
| `--entry`                | —     | string | `./main.js` | Code entry point of the build.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `--preset`               | —     | string | —           | Preset to build the project with, when you want a preset other than the project's own. The preset names are the ones `azion list presets` prints. For more information, refer to [Azion CLI presets](/en/documentation/devtools/cli/resources/presets/).                                                                                                                                                                                                                  |
| `--skip-framework-build` | —     | —      | —           | Skips the framework build that runs before the Azion build. Use it when you already built the framework yourself.                                                                                                                                                                                                                                                                                                                                                         |
| `--use-node-polyfills`   | —     | string | —           | Adds Node.js polyfills to the build, so code that calls Node.js-specific APIs stays compatible.                                                                                                                                                                                                                                                                                                                                                                           |
| `--use-own-worker`       | —     | string | —           | Tells the build that your code declares its own worker expression, such as `addEventListener("fetch")`, so the build does not inject a provider. Use it when your code already sets up the worker.                                                                                                                                                                                                                                                                        |

The build writes these files into `.edge`:

- `.edge/manifest.json`, the manifest that `azion deploy --local` reads.
- `.edge/functions/handler.js` for a static preset, or `.edge/functions/index.js` for the JavaScript preset.
- `.edge/storage/metadata.json` and a storage folder named after the bucket and the storage prefix.

Until the first deploy, the storage folder has the literal names `$BUCKET_NAME/$BUCKET_PREFIX`, the placeholders in the project's `azion.config` file. The deploy replaces the placeholders in that file with the bucket name and a storage prefix. For the `html` preset, the build creates no `dist` folder.

`azion deploy --local` runs the same build before it uploads the files. Use `azion build` to check a build on your machine before you deploy it.

---

## Examples

Each example shows the command and the output it prints.

### Build a static site

This command builds a site set up with the `html` preset:

```bash
azion build
```

The command runs the Azion Bundler with the project's preset and prints the path of the manifest it generates:

```text
Building your Application. This process may take a few minutes
Running build step command:

$ npx --yes  @aziontech/bundler@1.2.0 build --preset html --config-version 4
…
[Azion] [Build] › ℹ  info      Using preset: html
[Azion] [Pre-Build] › ℹ  info      Starting pre-build...
[Azion] [Pre-Build] › ℹ  info      Pre-build completed successfully
[Azion] [Build] › ℹ  info      Using built-in handler from "html" preset.
[Azion] [Build] › ℹ  info      Starting build...
[Azion] [Build] › ✔  success   Build completed successfully
[Azion] [Post-Build] › ℹ  info      Starting post-build...
[Azion] [Post-Build] › ✔  success   Post-build completed successfully
[Azion] [Storage] › ℹ  info      Using provided prefix for storage '$BUCKET_NAME': $BUCKET_PREFIX
[Azion] [IaC] › ✔  success   Manifest generated successfully at <project-dir>/.edge/manifest.json
Your Application was built successfully
```

After the build, the `.edge` folder holds this tree. The tree holds `handler.dev.js` when `azion dev` has run in the project before the build:

```text
.edge
.edge/functions
.edge/functions/handler.dev.js
.edge/functions/handler.js
.edge/manifest.json
.edge/storage
.edge/storage/$BUCKET_NAME
.edge/storage/$BUCKET_NAME/$BUCKET_PREFIX
.edge/storage/metadata.json
```

### Build a framework project

This command builds a project set up with the `angular` preset:

```bash
azion build
```

In the pre-build step, the Azion Bundler runs the framework's own build, here `ng build`, and then the Azion build. `--skip-framework-build` leaves out the framework build:

```text
Building your Application. This process may take a few minutes
Running build step command:

$ npx --yes  @aziontech/bundler@1.2.0 build --preset angular --config-version 4
…
[Azion] [Build] › ℹ  info      Using preset: angular
[Azion] [Pre-Build] › ℹ  info      Starting pre-build...
…
[Angular] › ℹ  info
> angular-boilerplate@22.0.2 build
> ng build --output-path=./dist

[Angular] › ℹ  info      ❯ Building...

[Angular] › ℹ  info      ✔ Building...

[Angular] › ℹ  info      Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-JHJQWKMP.js      | main          | 218.66 kB |                59.77 kB
polyfills-5CFQRCPP.js | polyfills     |  34.59 kB |                11.33 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 253.24 kB |                71.11 kB

Application bundle generation complete. [1.759 seconds] - 2026-01-01T12:00:00.833Z

[Angular] › ℹ  info      Output location: <project-dir>/dist

[Azion] [Pre-Build] › ℹ  info      Pre-build completed successfully
[Azion] [Build] › ℹ  info      Using built-in handler from "angular" preset.
[Azion] [Build] › ℹ  info      Starting build...
[Azion] [Build] › ✔  success   Build completed successfully
[Azion] [Post-Build] › ℹ  info      Starting post-build...
[Azion] [Post-Build] › ✔  success   Post-build completed successfully
[Azion] [Storage] › ℹ  info      Using provided prefix for storage '$BUCKET_NAME': $BUCKET_PREFIX
[Azion] [IaC] › ✔  success   Manifest generated successfully at <project-dir>/.edge/manifest.json
Your Application was built successfully
```

The framework writes its output to `dist`, and the Azion build writes the same `.edge` tree as a static site, without `handler.dev.js`.

---

## Related resources

- [Global options](/en/documentation/devtools/cli/globals.md): The options every command accepts, such as `--debug`, `--format`, and `-y`.
- [Azion CLI deploy](/en/documentation/devtools/cli/deploy.md): The command that deploys the project, building it first unless you skip the build.
- [Azion CLI dev](/en/documentation/devtools/cli/dev-command.md): The command that builds the project and serves it on your machine.
- [Azion CLI presets](/en/documentation/devtools/cli/resources/presets.md): The preset names that `--preset` takes.
