89

ng serve is not building to the path that I have set in my angular-cli.json in apps[0].outDir.

ng build works correctly and builds to the path that I have specified.

2

2 Answers 2

128

It's correct that ng serve builds in memory.

Angular CLI does not have support for running a server and writing to disk at the same time.

If you are using your own server, etc., you can use ng build --watch, which will watch files just like ng serve, but will write them to disk, and will not run a server.

Check this official documentation on how to serve files from disk:
https://github.com/angular/angular-cli/wiki/stories-disk-serve

7
  • 1
    Thanks for above. Would ng build concatenate and minify files? I ideally during development, I wouldn't want it to. We build on "dev containers" and don't need to spin up a development server. May 10, 2017 at 11:40
  • 6
    It works in dev mode by default, which doesn't do minification / concatenation etc. When you are ready to ship, you run ng build -prod to get the optimized build. It does not spin a server either way. At work I host the site in IIS and develop using ng build --watch.
    – Meligy
    May 11, 2017 at 0:17
  • 1
    Is there any way I can get the browser to auto-refresh every time the build is done, like ng serve does?
    – iMe
    Jul 7, 2017 at 6:54
  • Nothing built into the CLI itself does that, because no server to call the browser to trigger the refresh.
    – Meligy
    Jul 7, 2017 at 7:38
  • Can I customize ng serve command? I mean I want to run some bash commands say node abc.js before every ng serve is it possible? Aug 8, 2019 at 11:54
15

Output is not written to disk when using ng serve. Everything will be kept in memory. Source: Where are files stored when running ng serve?

1
  • 1
    Thanks Steven! I missed that question. Oct 19, 2016 at 12:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.