22

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.

2
  • Try: $ rm -rf dist tmp node_modules && npm install && ng build Commented Aug 19, 2016 at 8:55
  • I edited the question, ng build generates a dist folder just fine, that is not the problem. Earlier ng serve also generated the dist folder. This is not the case anymore. I want that behaviour back. Commented Aug 19, 2016 at 9:17

4 Answers 4

27

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

ng serve works only in-memory now.

Sign up to request clarification or add additional context in comments.

3 Comments

I know, that's why i asked the question in the first place :) The proxy functionality makes this obsolete though. I just proxy the api instead of serving the dist folder with spring boot.
I use the proxy and now with the latest cli it doesn't find my css etc. like it did before. Is there a way to proxy just the api calls and not anything else?
How can i trace my compile-time errors then? I use aot and I get some errors with line numbers but I cannot see the file.
26

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

Explanation:

By running ng build --help, we can see what the --watch flag does:

--watch Run build when files change.

1 Comment

I know this question is a bit dated but this solution only seemed to have worked partially for me. For instance in the very basic scenario where my app.component.ts has a variable called title and I display it using {{}} in app.component.html, changing it will rebuild the package but the variable won't be updated (similarly if I add a class variable and try to display it) the only thing that worked was adding html content in the view. I refreshed and reloaded and that didn't do anything
7

In the root folder of your angular2 project, run:

ng build

Or for production:

ng build --prod

This command will generate the dist folder.

2 Comments

Thanks, i know that, this is not the point: ng build does not compile on change like ng serve does.
it doesn't for angular cli 7
0

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.

1 Comment

The above option wont work if you are using angular 6 or above, it was removed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.