-
-
Save jasonals/d984311278332b1e9f23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment