Live Server is a great tool for working with Javscript. It automatically reloads our code any time changes are made to files in the folder where Live Server is running. This becomes an issue when using a tool like json-server
with a .json
file in the same directory - since changes you make using POST/PATCH/DELETE requests will update the .json
file, these changes will also cause your app to reload.
You can solve this by telling Live Server to ignore changes to certain files. Open your VSCode preferences by pressing command + shift + p
in VSCode and searching for "Preferences: Open Settings (JSON)". Then, add the following lines to the settings.json
file:
"liveServer.settings.ignoreFiles": [
".vscode/**",
"**/db.json"
],
This will tell Live Server to ignore changes to any db.json
files. You can add other files to this as well if you wish.
My Vs Code on Ubuntu has three preferences setting. Where should I add?
