MMM
MMM

Reputation: 287

Angular and VS Code disable automatic reload/refresh

when I am running my Angular app in the CLI with "ng serve", on every tiny change in the code, my app gets reloaded / refreshed. How can I stop that behaviour? I know I have seen the command ng serve --live-reload false, but apparently, I have to reload everything then in browser by hand.

Weirdly, on my other desktop PC, not my laptop, I can just reload everything by default in VSCode by pressing CTRL+S, otherwise, no changes or reloads are done during changing the code otherwise. I would like to have this behaviour by default on my laptop also... How can I do that?

Upvotes: 5

Views: 11177

Answers (3)

Tomas Vancoillie
Tomas Vancoillie

Reputation: 3868

I like the Auto Save feature, because of ... obvious reasons.

You have different settings:

off - A dirty file is never automatically saved.
afterDelay - A dirty file is automatically saved after ...
onFocusChange - A dirty file is automatically saved when the editor loses focus.
onWindowChange - A dirty file is automatically saved when the window loses focus.

My preference goes to onFocusChange

You work in a file of choice without the auto reload and jumping cursors, when you are done the changes can be build

P.S: Why have I waited so long to search this annoying problem

Upvotes: 2

Gianni Azizi
Gianni Azizi

Reputation: 250

No CLI command will solve the problem. This comes from your IDE which saves your file each time the code is modified. I think you can change that in the settings of it so that it only records at your request.

Upvotes: 2

Teddy Sterne
Teddy Sterne

Reputation: 14221

Turn of the autoSave feature. This feature automatically saves your files on any change which cause ng serve to reload the files.

To Change:

File > Preferences > Settings > Search autoSave > select off

User Settings after change:

"files.autoSave": "off",

Upvotes: 5

Related Questions