ng serve doesn't generate dist folder anymore

2019-02-16 09:36发布

问题:

I initially started a project with beta 10 of the angular-cli, when I run ng serve at that point of time the dist folder would contain the compiled files that were generated by ng serve.

Now I upgraded my app to RC5 and beta 11.webpack of the angular-cli and ng serve doesn't generate the dist folder anymore. This is problematic because I have a Spring Boot backend which is configured to map the dist folder as it's static folder.

Is there a way to get this behaviour with the webpack angular-cli as well?

Exact version of angular-cli is: 1.0.0-beta.11-webpack.2

Edit: the point is that I need the auto compile from ng serve, I don't want to run ng build every time I make a change in the source files.

回答1:

Just use ng build --watch. It will be rebuilding project on changes.



回答2:

The new angular-cli version with webpack will generate dist folder only after ng build.

ng serve works only in-memory now.



回答3:

In the root folder of your angular2 project, run:

ng build

Or for production:

ng build --prod

This command will generate the dist folder.



回答4:

In the root folder of your project run

ng serve --delete-output-path=false

or

ng serve --no-delete-output-path

This worked for me.