watch-make
A file watcher that executes Make and broadcasts the changes through an HTTP server.
This lets you rebuild source files and reload your application.
Install
npm i @jamen/watch-make
Usage
watch-make
Watches files and executes Make targets. It also starts a server and broadcasts the file changes through it, allowing your app to reload.
watch-make -p 5001 "src/*.js" "src/*.scss" "src/asset"
Connecting to the server
You use the EventSource
web API to connect to the reload server.
const src = new EventSource('http://localhost:5001')
src.onmessage = message => {
console.log('file', message.data)
}
For example, a simple auto-reloader:
new EventSource('https://localhost:5001').onmessage = () => window.location.reload()