Using
chokidar.watch(mainFile).on('change', () => {
app.relaunch();
app.exit(0);
});
I can have my Electron app auto-reload on source change. However since the main process is killed, I loose the terminal output which is necessary for debugging. Is there a way to use app.relaunch() retaining the stdio of the parent process?
Disclaimer: below I explain the setup I found as a decent workaround in 2016. Not sure if there is a better way in 2018.
Reloading of my Electron app is handled in two parts:
Rendered process
I use electron-reload listening for changes only within the
rendererfolder:Main process
Auto-reload handled "manually" via a Gulp script, as follows:
Running the app with
gulp run devwill start a watcher and kill/restart the entire application on file change.