Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  4] [ 5]  / answers: 1 / hits: 18467  / 8 Years ago, wed, august 31, 2016, 12:00:00

Are there any tools to live reload electron app when code is changed similar to browser-sync for web?



Whenever we change code for electron app, I am terminating existing running process and relaunching with
electron .
Are they any tools to reload electron app automatically when code is changed.


More From » electron

 Answers
2

The best tool (and easiest) I've found is electron-reload:



// main.js
const electron = require('electron');
const { app, BrowserWindow } = electron;
const path = require('path');

// the first argument can be: a file, directory or glob pattern
require('electron-reload')(__dirname + '/app/index.html', {
electron: path.join(__dirname, 'node_modules', '.bin', 'electron')
});

let mainWindow;

app.on('ready', () => {
mainWindow = new BrowserWindow({
// ...
});
mainWindow.setMenu(null);

mainWindow.loadURL(`file://${__dirname}/app/index.html`);
process.env.NODE_ENV !== 'production' && mainWindow.openDevTools();
});

[#60854] Monday, August 29, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jerome

Total Points: 592
Total Questions: 98
Total Answers: 101

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;