111

When serving my app with the Angular cli, how do I disable auto-reload?

ng --help mentions the --live-reload option, but I can't make it work.

ng serve --live-reload=false or ng serve --live-reload false do not work

EDIT : it seems to be a bug https://github.com/angular/angular-cli/issues/1755

maxbellec
  • 16,093
  • 10
  • 36
  • 43

4 Answers4

184

Just do ng serve --live-reload false or ng serve --no-live-reload

It used to not work, this PR solved it.

Bruno Medeiros
  • 2,251
  • 21
  • 34
maxbellec
  • 16,093
  • 10
  • 36
  • 43
  • 1
    Can I stop reloading on some particular files like I want to stop reloading on changes in css files, is it possible ? – Pardeep Jain Jun 06 '18 at 09:58
  • 4
    for me i had to add an equals sign `ng serve --live-reload=false` – cup_of Aug 20 '18 at 22:54
  • not working for me with `--aot --prod`. haven't tried other settings, but this isn't working. – Simon_Weaver Sep 14 '18 at 01:54
  • 3
    why would develop with `--prod` mode on, though? – maxbellec Sep 14 '18 at 09:41
  • @maxbellec because development includes end to end testing. I might use it 2% of the time but I still want the option to test all my production config - and any nuances of production builds. Since I can now use argo tunnel through cloudflare (which caches) to reverse proxy to my machine I can get a pretty good idea how fast the site will be on a cell data connection without needing a real staging environment. – Simon_Weaver Sep 14 '18 at 21:04
  • It seems I was mistaken. These settings do work `ng serve --source-map=false --aot --prod --live-reload=false`. (I prefer to suppress source maps for speed). These are my 'dog walking' settings in conjunction with cloudflare argo tunnel - so I can quickly test my environment while walking the dog. – Simon_Weaver Sep 19 '18 at 05:05
  • do you know if its possible to configure ng serve to reload the page and then take you to a specific path after the reload? – devdropper87 Oct 02 '20 at 18:39
23

serve your application with this command:

ng serve --live-reload=false

Or for modern ng:

ng serve --no-live-reload

if you want to run your application in prod mode, use following command

ng serve --source-map=false --aot --prod --live-reload=false
AnasSafi
  • 5,353
  • 1
  • 35
  • 38
s sharif
  • 724
  • 1
  • 10
  • 19
12

I think you only want to disable the rebuild on change option

Just try:

$ ng serve --watch=true|false
Pedro Lopez
  • 147
  • 1
  • 6
0

The solution for this is to upgrade the version of the CLI you are using. The CLI now uses in memory for the build process and is no longer writing to disk. This helps with the antivirus/disk write issue.

zmanc
  • 5,201
  • 12
  • 45
  • 90
  • it might fix the problem from the first comment, but I believe it does not solve the real problem, there is still (to my knowledge, last time I checked in the Github discussions) no way to make `--live-reload` work with the cli – maxbellec Feb 16 '17 at 18:08
  • live-reload disable is coming back, but I guess the other question is why is this a need? I have not seen a use case for disabling it. – zmanc Feb 16 '17 at 18:15
  • 3
    it mostly annoys me when I'm editing a template, then I come back to the browser the check something in the dev tools only to find out the page I'm working on is not available since the app is broken (it refreshed before I finished editing the template) and I can't see the page anymore – maxbellec Feb 17 '17 at 10:02
  • seeing the number of comment on the github issue, I guess I'm not the only one being annoyed by this – maxbellec Feb 17 '17 at 10:02
  • Still hitting this. I'm trying to run `ng serve` via cloudflare (they have a new tunnel called argo tunnel that allows me to reverse proxy from my dev machine). I want to test on proper https, on a CDN without a proper build. Also sometimes I may be editing realtime with others previewing the site in a meeting and I don't want it reloading until I tell them to hit reload. – Simon_Weaver Sep 14 '18 at 01:54
  • @Simon_Weaver instead of a ng serve you may want to try doing a ng build —watch. It will have the same affect of rebuilding the files but leave the responsibility of the actual serving to your CDN / or https server. – zmanc Sep 14 '18 at 10:31