Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// devDependencies in package.json:
"require-reload": "0.2.2",
"react-transform-hmr-no-accept": "1.0.1", // not published, get it here: https://github.com/brandonbloom/react-transform-hmr
// in babelrc:
"env": {
"development": {
"plugins": [
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-hmr-no-accept",
"imports": [
"react"
],
"locals": [
"module"
]
}
]
}
]
]
}
}
// in the Electron main thead:
fs.watch(__dirname + '/views', {recursive: true}, (event, filename) => {
if (filename.endsWith('.js')) {
mainWindow.webContents.send('reload', filename);
}
});
// in the main window renderer thread:
import {ipcRenderer} from 'electron';
ipcRenderer.on('reload', (event, filename) => {
reload('./views/' + filename);
});
@gaearon
Copy link

gaearon commented Dec 31, 2015

Not much. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment