Skip to content
Latchkey

ng build --configuration production: Angular

ng build --configuration production compiles an Angular app with AOT, optimization, and budget checks enabled.

The Angular CLI drives builds through named configurations in angular.json. The production configuration turns on the optimizations and the size budgets that can fail a CI build.

What it does

ng build --configuration production runs an ahead-of-time (AOT) production build: it optimizes, minifies, hashes output, and enforces the bundle-size budgets declared in angular.json. It writes to the configured output path (dist/ by default).

Common usage

Terminal
ng build --configuration production
ng build --configuration production --output-path dist/app --base-href /app/
# older CLI shorthand
ng build --prod

Options

FlagWhat it does
--configuration <c>Named build config from angular.json (e.g. production)
--output-path <dir>Where to write the build
--base-href <path>Base href injected into index.html
--source-mapEmit source maps
--aotAhead-of-time compilation (on by default in prod)
--no-progressSilence the progress bar in CI logs

In CI

Set --base-href to match the deploy sub-path or routing and asset links break. Watch the size budgets: a dependency bump can push you over and fail the build. Large apps may need NODE_OPTIONS=--max-old-space-size to avoid heap exhaustion.

Common errors in CI

"Error: bundle initial exceeded maximum budget. Budget 500.00 kB was not met by ..." means a bundle grew past the angular.json budget; trim it or raise the budget deliberately. "Cannot determine project or target" means --configuration references a config not in angular.json. Template type errors surface as "error NG..." during AOT.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →