7

I know we can disable the live reload when starting angular cli (see Angular cli - how to disable auto reload when ng serve)

I would like to be able to disable it (and re-enable it later on) from the browser's console by setting a global variable or calling a global command. Is it possible ?

Benoît
  • 1,080
  • 11
  • 28

1 Answers1

4

I know this is old but I came across it while trying to do the same thing.

While I couldn't find a global object to modify I did find a couple of other methods.

  1. You can you use the "Request blocking" feature of your browsers dev tools.

    • Open the Request blocking tab in dev tools
    • Add the URL your webpack dev server hot reload is trying to connect to e.g. ' http://localhost:4201/sockjs-node/*'
    • You then have to reload the page to make this work
  2. If you don't want to reload you can edit the value of the webpack client property 'hotReload' in memory.

    • Open the js file 'webpack:///(webpack)-dev-server/client' in the sources tab of dev tools.
    • Add a breakpoint in the code on the first line of the reloadApp() function where it checks the hotReload property (for me this was line 220)
    • trigger a hot reload by changing a file, your browser should break at your breakpoint.
    • you can now set the value of hotReload to false in the current scope section of the debugger.
    • Now hit play and remove the breakpoint. Reloads should now be ignored.

I did all this in Chrome but it may work the same in your browser of choice.

mfa
  • 601
  • 6
  • 19
  • 1
    Thanks for your answer. Your two methods could work, but I must say I do not have the need any more. It could help others, so I am glad to accept it.My request came from Webstorm automatically saving my files on blur and causing reloads sooner than I wanted. I unchecked this auto-save, and I now control the save and therefore the reload. – Benoît Nov 12 '18 at 21:02