Skip to content

build

Terminal window
nx build my-app

Runs astro build for the project. Before that it copies the versions of astro and all @astrojs/* packages from the root package.json into the one of the project; How it works explains why.

The target is cached, with dist/<project root> in the workspace as its output.

Option Type Default Description
outputPath string none Output directory, overriding outDir of the Astro config. A relative path starts at the project directory. Keep it inside the outputs of the target, or the cache does not see it.
mode string none Astro mode, passed as --mode: it selects .env.<mode> files and import.meta.env.MODE. Static or server output is chosen by output in the Astro config, not here.
verbose boolean false Verbose output.
root string none Project directory. Nx knows it, so you rarely set this.
config string none Path of the Astro config file. Without it Astro finds astro.config.* itself.
site string none Overrides site of the Astro config.
base string none Overrides base of the Astro config.
sourcemap boolean false Deprecated, has no effect. Set vite.build.sourcemap in the Astro config.
clean boolean true Deprecated, has no effect. Astro always empties its output directory.
additionalArgs array none More command-line arguments for Astro.
generatePackageJson boolean false Writes a package.json and a lock file with the dependencies of the project to outputPath. Set outputPath too: without it they are written to dist in the project directory, whatever outDir says. No lock file is written with Bun.
includeDevDependenciesInPackageJson boolean false Includes development dependencies in that package.json.
skipOverrides boolean false Leaves the overrides field out of that package.json.
skipPackageManager boolean false Leaves the packageManager field out of that package.json.

Build with the variables of .env.staging and another site URL:

Terminal window
nx build my-app --mode=staging --site=https://staging.example.com
nx-astro 3.2.0 · MIT Developed by