Azion CLI build
Azion CLI command that builds a project on your machine and writes the result to the .edge folder, with every flag, its type, and its default.
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.
Usage
azion build reads the project settings from the azion folder of the current directory. Run it in the root folder of the project:
| 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. |
--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 thatazion deploy --localreads..edge/functions/handler.jsfor a static preset, or.edge/functions/index.jsfor the JavaScript preset..edge/storage/metadata.jsonand 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:
The command runs the Azion Bundler with the project’s preset and prints the path of the manifest it generates:
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:
Build a framework project
This command builds a project set up with the angular preset:
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:
The framework writes its output to dist, and the Azion build writes the same .edge tree as a static site, without handler.dev.js.