Setting up Electron hot reloading
1 min read

Setting up Electron hot reloading

I am currently playing with ElectronJS to build a personal project. It was a pain having to restart the application every time I made a change in the source files. After an hour of continually stopping and rerunning npm start, I decided I had enough.

I was able to set up Electron hot reloading with the npm module electron-reloader.

Assuming you have bootstrapped the Electron quick start guide, we can install electron-reloader.

npm install --save-dev electron-reloader

Open your main.js file, and add the following snippet after the path import.

try {
  require('electron-reloader')(module)
} catch (_) {}

You should rerun your application, npm start and your Electron application will hot reload after every file change.