Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Created December 31, 2015 21:59
Show Gist options
  • Save brandonbloom/188c91834de7ab2cee73 to your computer and use it in GitHub Desktop.
Save brandonbloom/188c91834de7ab2cee73 to your computer and use it in GitHub Desktop.
// 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