elemon is a tiny module that tries to provide a simple and yet efficient live-reload tool when developing Electron applications. You just need to pass the app and BrowserWindows and the name of the files that are associated with them as a parameter to the elemon function after your app is ready. Please check out the example below to see how you can easily use it to watch your app and cleanly reload it upon any changes. If the changed
file is the main app file, then it relaunch the app and exit the current instance. If the changed file is a file that is associated with a browser window, then that window will only be reloaded.
In fact, setting up a clean live-reload tool when developing an electron application is super simple by using the Electron API. The api already comes with whatever you need; just add a watcher (like chokidar or whatever watcher you like) and you are all set.
Install
npm i elemon --save-dev.
Usage
elemon(refs)
refs{Object} object that takes references to app and browser windows objects and resources
res{Array<String>} array of any file name that is somehow associated with this browser window
if you want to watch all files in dir, or if you want the bw to be reloaded on any changes and not necessarily changes on specific file(s), leave the res as empty []. (thanks jaime-ez for adding this option)