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
ng build --configuration production
ng build --configuration production --output-path dist/app --base-href /app/
# older CLI shorthand
ng build --prodOptions
| Flag | What 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-map | Emit source maps |
| --aot | Ahead-of-time compilation (on by default in prod) |
| --no-progress | Silence 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.