Where does `ng serve` output files to?
34,153
Solution 1
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
Solution 2
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?
Related videos on Youtube
Comments
-
Daniel Patrick about 4 years
ng serve
is not building to the path that I have set in my angular-cli.json inapps[0].outDir
.ng build
works correctly and builds to the path that I have specified.-
Jsandesu over 5 yearsPossible duplicate of Where are files stored when running ng serve?
-
Daniel Patrick over 5 yearsPerhaps is a duplicate... but it seems that when folks google this question the wording here somehow serves them better, this has 4x the views. What's the standard way of resolving that?
-
-
Daniel Patrick over 7 yearsThanks Steven! I missed that question.
-
user1275105 almost 7 yearsThanks 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.
-
Meligy almost 7 yearsIt 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 usingng build --watch
. -
iMe almost 7 yearsIs there any way I can get the browser to auto-refresh every time the build is done, like
ng serve
does? -
Meligy almost 7 yearsNothing built into the CLI itself does that, because no server to call the browser to trigger the refresh.
-
Pardeep Jain over 4 yearsCan I customize
ng serve
command? I mean I want to run some bash commands saynode abc.js
before everyng serve
is it possible? -
Meligy over 4 yearsThere might be something you can do in the
architect/serve
part of theangular.json
file, but usually when people want to do that they make it an npm script inpackage.json
and add what they want beforeng serve
and call this script instead of callingng serve
directly. -
tinkering.online about 4 years@iMe I found something on the official angular pages that might be of interest for your live build + serve question: angular.io/guide/deployment#building-and-serving-from-disk