electron-webpack-plugin

Webpack plugin to restart Electron.
Requires a peer dependency of electron
.
NOTE: As of version 2.0.0
, relaunchPathMatch
has changed to test
- which is a regex to test the module ID against.
API
new ElectronPlugin(options: object)
options
new ElectronPlugin({
test: /^.\/src\/browser/,
path: "./output",
args: ["--enable-logging"],
options: {
env: {NODE_ENV: "development"}
}
})
Example
With this config, Electron will restart when any module in ./src/browser
changes.
const ElectronPlugin = require("electron-webpack-plugin");
module.exports = {
entry: {
"browser/index": "./src/browser/index.js",
"renderer/index": "./src/renderer/index.js",
},
output: {
path: "./output",
filename: "scripts/[name].js"
},
plugins: [
new ElectronPlugin({
test: /^.\/src\/browser/,
path: "output"
})
],
target: "electron"
};
With webpack-dev-server
You will need to use write-file-webpack-plugin,
to allow Electron to access the output path.
You will also need to add the following options:
devServer: {
inline: false
}
You will also need to add the dev server client to your renderer entry point,
if it is not already:
"renderer/index": [
"webpack-dev-server/client?http://localhost:3000",
"./src/scripts/renderer/index.js"
]
This will allow HMR with inline: false
.
(replace http://localhost:3000
with whatever your dev server URL is)