Search code examples
reactjswebpackelectronwebpack-dev-serverwebpack-hmr

How to use Hot Module Replacement with Electron


I’d like to use HMR with my React Electron app. How would I do that? Do I need web pack? How do I integrate it with Electron?


Solution

  • You use a webpack config just like you would with a normal web app.

    The settings depend on wether you are using react-hot-loader 2 or 3 (beta)

    You then set the src attribute in your index.html file to wherever your webpack dev server is serving the bundle from. Usually: localhost:8080/bundlename.js

    Here is the walkthrough for react-hot-loader 2: http://gaearon.github.io/react-hot-loader/getstarted/