0% found this document useful (0 votes)
10 views

Angular - NG Build

The ng build command compiles an Angular application or library into an output directory named dist/ at the given output path. It uses the esbuild build tool with configuration options specified in the angular.json file or a named alternative configuration.

Uploaded by

Babu Sharath
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Angular - NG Build

The ng build command compiles an Angular application or library into an output directory named dist/ at the given output path. It uses the esbuild build tool with configuration options specified in the angular.json file or a named alternative configuration.

Uploaded by

Babu Sharath
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

ng build

Compiles an Angular application or library into an output directory

named dist/ at the given output path.

ng [project]

ng [project]

Description 

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 esbuild  build tool, with default

con�guration options speci�ed in the workspace con�guration �le

( angular.json ) or with a named alternative con�guration. A

"development" con�guration is created by default when you use the CLI

to create the project, and you can use that con�guration by specifying

the --configuration development .

The con�guration options generally correspond to the command

options. You can override individual con�guration defaults by specifying

the corresponding options on the command line. The command can

accept option names given in dash-case. Note that in the con�guration


�le, you must specify names in camelCase.

Some additional options can only be set through the con�guration �le,

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 �ngerprinted at the root of the

output folder.

For further details, see Workspace Con�guration.

Arguments
ARGUMENT DESCRIPTION VALUE TYPE

project The name of the string

project to build. Can be

an application or a

library.

Options
OPTION DESCRIPTION VALUE TYPE

--allowed-common-js-dependencies A list of array

CommonJS or

AMD packages

that are

allowed to be

used without a

build time

warning. Use

'*' to allow

all.

--aot Build using boolean

Ahead of Time

compilation.

--app-shell Generates an boolean

application

shell during

build time.

--base-href Base url for the string

application

being built.
OPTION DESCRIPTION VALUE TYPE

--browser The full path string

for the browser

entry point to

the application,

relative to the

current

workspace.

--clear-screen Automatically boolean

clear the

terminal screen

during rebuilds.
OPTION DESCRIPTION VALUE TYPE

--configuration One or more string

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://angul

ar.io/guide/

workspace-c

onfig#altern

ate-build-con

figurations

Aliases: -c
OPTION DESCRIPTION VALUE TYPE

--cross-origin Define the none |


anonymous |
crossorigin
use-
attribute credentials
setting of

elements that

provide CORS

support.

--delete-output-path Delete the boolean

output path

before building.
OPTION DESCRIPTION VALUE TYPE

--deploy-url Customize the string

base path for

the URLs of

resources in

'index.html' and

component

stylesheets.

This option is

only necessary

for specific

deployment

scenarios, such

as with Angular

Elements or

when utilizing

different CDN

locations.
OPTION DESCRIPTION VALUE TYPE

--external-dependencies Exclude the array

listed external

dependencies

from being

bundled into

the bundle.

Instead, the

created bundle

relies on these

dependencies

to be available

during runtime.

--extract-licenses Extract all boolean

licenses in a

separate file.

--help Shows a help boolean

message for

this command

in the console.

--i18n-duplicate-translation How to handle warning |


error |
duplicate
ignore
translations for

i18n.
OPTION DESCRIPTION VALUE TYPE

--i18n-missing-translation How to handle warning |


error |
missing
ignore
translations for

i18n.

--index Configures the string

generation of

the

application's

HTML index.

--inline-style-language The stylesheet css | less


| sass |
language to
scss
use for the

application's

inline

component

styles.

--localize Translate the boolean

bundles in one

or more

locales.

--named-chunks Use file name boolean

for lazy loaded

chunks.
OPTION DESCRIPTION VALUE TYPE

--optimization Enables boolean

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://angul

ar.io/guide/

workspace-c

onfig#optimi

zation-config

uration

.
OPTION DESCRIPTION VALUE TYPE

--output-hashing Define the none | all


| media |
output filename
bundles
cache-busting

hashing mode.

--output-path Specify the string

output path

relative to

workspace

root.

--poll Enable and number

define the file

watching poll

time period in

milliseconds.
OPTION DESCRIPTION VALUE TYPE

--polyfills A list of array

polyfills to

include in the

build. Can be a

full path for a

file, relative to

the current

workspace or

module

specifier.

Example:

'zone.js'.

--prerender Prerender boolean

(SSG) pages of

your

application

during build

time.
OPTION DESCRIPTION VALUE TYPE

--preserve-symlinks Do not use the boolean

real path when

resolving

modules. If

unset then will

default to

true if

NodeJS option

--preserve-

symlinks is set.

--progress Log progress to boolean

the console

while building.

--server The full path string

for the server

entry point to

the application,

relative to the

current

workspace.

--service-worker Generates a string

service worker

configuration.
OPTION DESCRIPTION VALUE TYPE

--source-map Output source

maps for

scripts and

styles. For

more

information,

see

https://angul

ar.io/guide/

workspace-c

onfig#sourc

e-map-config

uration

You might also like