Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build with watch enabled using angular-cli?

I don't want to use serve, I know it watches for changes, builds and serves. I want to build upon changes. According to "ng help", build takes parameter --watch

ng build Builds your app and places it into the output path (dist/ by default). --watch (Boolean) (Default: false) aliases: -w --watcher (String)

I tried both -w and --watcher but it just gives error.

>ng build -w  Path must be a string. Received null 
like image 319
nurp Avatar asked Oct 24 '16 17:10

nurp


People also ask

What is the command to build angular project?

Syntax. ng build command compiles an angular application/library into an output directory named dist at given path.

What is watch mode in angular?

You may use the watch option on Angular build for updating the output as and when developers make changes to the code. It is very similar to serve, except that the application runs a different web server from the default dev server.

Which CLI command is used to build the angular application?

The ng new command creates an Angular workspace folder and generates a new application skeleton. A workspace can contain multiple applications and libraries. The initial application created by the ng new command is at the top level of the workspace.


1 Answers

I don´t know if it´s a bug or just not documented, but it seems that you need to add a output path for watching with ng build -o dist -w while dist is your output path.

Update:

The command is now: ng build -op dist -w

Update 2:

The command is now: ng build --output-path dist --watch

like image 73
Stefan Negele Avatar answered Sep 19 '22 11:09

Stefan Negele