Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory.
ng build <project> [options]
ng b <project> [options]
Uses the webpack build tool, with default configuration options specified in the workspace configuration file (
angular.json) or with a named alternative configuration. A "production" configuration is created by default when you use the CLI to create the project, and you can use that configuration by specifying the
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
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.
The name of the project to build. Can be an app or a library.
Build using Ahead of Time compilation.
Base url for the application being built.
(experimental) Output file path for Build Event Protocol events
Enables '@angular-devkit/build-optimizer' optimizations when using the 'aot' option.
Use a separate bundle containing code used across multiple bundles.
A named build target, as specified in the "configurations" section of angular.json. Each named target is accompanied by a configuration of option defaults for that target.
Delete the output path before building.
URL where files will be deployed.
Output in-file eval sourcemaps.
Extract css from global styles into css files instead of js ones.
Extract all licenses in a separate file.
Run the TypeScript type checker in a forked process.
Shows a help message for this command in the console.
Localization file to use for i18n.
Format of the localization file specified with --i18n-file.
Locale to use for i18n.
How to handle missing translations for i18n.
The name of the index HTML file.
List of additional NgModule files that will be lazy loaded. Lazy router modules will be discovered automatically.
The full path for the main entry point to the app, relative to the current workspace.
Use file name for lazy loaded chunks.
Path to ngsw-config.json.
Enables optimization of the build output.
Define the output filename cache-busting hashing mode.
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.
When true, sets the build configuration to the production target. All builds make use of bundling and limited tree-shaking. A production build also runs limited dead code elimination.
Output profile events for Chrome profiler.
Log progress to the console while building.
The path where style resources will be placed, relative to outputPath.
Generates a service worker config for production builds.
Show circular dependency warnings on builds.
Flag to prevent building an app shell.
Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or https://webpack.github.io/analyse.
Enables the use of subresource integrity validation.
The full path for the TypeScript configuration file, relative to the current workspace.
Use a separate bundle containing only vendor libraries.
Resolve vendor packages sourcemaps.
Adds more details to output logging.
Run build when files change.