How to reload the browser window when saving a file

Quick and easy way

I was working on a site using vanilla HTML + JS, but I missed one of the best features provided by those quick start packages (such as create-react-app or Vue CLI): when I save the file in the code editor, re Load the page.

The easiest way I found is to installbrowser-sync:

npm install -g browser-sync

Then run it in your project folder:

browser-sync start --server --files "."

The above command monitors all files in the current folder (and all subfolders) for changes, starts the web server on port 3000, opens a browser window to connect to the server.

The browser will refresh every time the file is changed.

Very useful when making prototypes!