Benoît
Benoît

Reputation: 1100

Angular Cli : disable live reload from browser's console

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 ?

Upvotes: 7

Views: 5213

Answers (1)

mfa
mfa

Reputation: 709

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.

Upvotes: 5

Related Questions