ng build

Compiles an Angular application or library into an output directory named dist/ at the given output path.

ng build [project]

ng b [project]


The command can be used to build a project of type "application" or "library". When used to build a library, a different builder is invoked, and only the ts-config, configuration, and watch options are applied. All other options apply only to building applications.

The application builder uses the webpack build tool, with default configuration options specified in the workspace configuration file (angular.json) or with a named alternative configuration. A "development" configuration is created by default when you use the CLI to create the project, and you can use that configuration by specifying the --configuration development.

The configuration options generally correspond to the command options. You can override individual configuration defaults by specifying the corresponding options on the command line. The command can accept option names given in either dash-case or camelCase. Note that in the configuration file, you must specify names in camelCase.

Some additional options can only be set through the configuration file, either by direct editing or with the ng config command. These include assets, styles, and scripts objects that provide runtime-global resources to include in the project. Resources in CSS, such as images and fonts, are automatically written and fingerprinted at the root of the output folder.

For further details, see Workspace Configuration.


Argument Description Value Type

The name of the project to build. Can be an application or a library.



Option Description Value Type Default Value

A list of CommonJS packages that are allowed to be used without a build time warning.


Build using Ahead of Time compilation.

boolean true

Base url for the application being built.


Enables advanced build optimizations when using the 'aot' option.

boolean true

Generate a seperate bundle containing code used across multiple bundles.

boolean true

One or more named builder configurations as a comma-separated list as specified in the "configurations" section in angular.json. The builder uses the named configurations to run the given target. For more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.

Aliases: -c


Define the crossorigin attribute setting of elements that provide CORS support.

none | anonymous | use-credentials none

Delete the output path before building.

boolean true

Deprecated: Use "baseHref" option, "APP_BASE_HREF" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url.

URL where files will be deployed.


Extract all licenses in a separate file.

boolean true

Shows a help message for this command in the console.


How to handle duplicate translations for i18n.

warning | error | ignore warning

How to handle missing translations for i18n.

warning | error | ignore warning

Configures the generation of the application's HTML index.


The stylesheet language to use for the application's inline component styles.

css | less | sass | scss css

Translate the bundles in one or more locales.


The full path for the main entry point to the app, relative to the current workspace.


Use file name for lazy loaded chunks.

boolean false

Path to ngsw-config.json.


Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.

boolean true

Define the output filename cache-busting hashing mode.

none | all | media | bundles none

The full path for the new output directory, relative to the current workspace. By default, writes output to a folder named dist/ in the current project.


Enable and define the file watching poll time period in milliseconds.


The full path for the polyfills file, relative to the current workspace.


Do not use the real path when resolving modules. If unset then will default to true if NodeJS option --preserve-symlinks is set.


Log progress to the console while building.

boolean true

The path where style resources will be placed, relative to outputPath.


Generates a service worker config for production builds.

boolean false

Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration.

boolean false

Generates a 'stats.json' file which can be analyzed using tools such as 'webpack-bundle-analyzer'.

boolean false

Enables the use of subresource integrity validation.

boolean false

The full path for the TypeScript configuration file, relative to the current workspace.


Generate a seperate bundle containing only vendor libraries. This option should only used for development.

boolean false

Adds more details to output logging.

boolean false

Run build when files change.

boolean false

TypeScript configuration for Web Worker modules.


© 2010–2022 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.