Documentation below is for CLI version 6 and we no longer accept PRs to improve this. For version 7 see here.
ng build compiles the application into an output directory.
The build artifacts will be stored in the
All commands that build or serve your project,
ng build/serve/e2e, will delete the output directory (
dist/ by default). This can be disabled via the
When building you can modify base tag (
<base href="/">) in your index.html with
--base-href your-url option.
All builds make use of bundling and limited tree-shaking, while
--prod builds also run limited dead code elimination via UglifyJS.
When using Build Optimizer the vendor chunk will be disabled by default. You can override this with
Total bundle sizes with Build Optimizer are smaller if there is no separate vendor chunk because having vendor code in the same chunk as app code makes it possible for Uglify to remove more unused code.
Resources in CSS, such as images and fonts, will be copied over automatically as part of a build. If a resource is less than 10kb it will also be inlined.
You’ll see these resources be outputted and fingerprinted at the root of
To build in ES2015 mode, edit
./tsconfig.json to use
"target": "es2015" (instead of
This will cause application TypeScript and Uglify be output as ES2015, and third party libraries to be loaded through the
es2015 entry in
package.json if available.
Be aware that JIT does not support ES2015 and so you should build/serve your app with
--aot. See https://github.com/angular/angular-cli/issues/7797 for details.
Flag to set configuration to “prod”.
Specify the configuration to use.
The name of the main entry-point file.
The name of the polyfills file.
The name of the TypeScript configuration file.
Enables optimization of the build output.
Path where output will be placed.
Build using Ahead of Time compilation.
Output in-file eval sourcemaps.
Resolve vendor packages sourcemaps.
Use a separate bundle containing only vendor libraries.
Use a separate bundle containing code used across multiple bundles.
Base url for the application being built.
URL where files will be deployed.
Adds more details to output logging.
Log progress to the console while building.
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.
Extract css from global styles onto css files instead of js ones.
Run build when files change.
Define the output filename cache-busting hashing mode.
Enable and define the file watching poll time period in milliseconds.
Delete the output path before building.
Do not use the real path when resolving modules.
Extract all licenses in a separate file, in the case of production builds only.
Show circular dependency warnings on builds.
Enables @angular-devkit/build-optimizer optimizations when using the ‘aot’ option.
Use file name for lazy loaded chunks.
Enables the use of subresource integrity validation.
Generates a service worker config for production builds.
Path to ngsw-config.json.
Flag to prevent building an app shell.
The name of the index HTML file.
Generates a ‘stats.json’ file which can be analyzed using tools such as: #webpack-bundle-analyzer’ or https://webpack.github.io/analyse.
Run the TypeScript type checker in a forked process.