https://github.com/geakstr/electron-watcher-webpack-plugin
⚡️ Live reload Electron main and renderers processes with webpack plugin
https://github.com/geakstr/electron-watcher-webpack-plugin
electron live-reload livereload plugin watch webpack webpack-plugin
Last synced: 6 months ago
JSON representation
⚡️ Live reload Electron main and renderers processes with webpack plugin
- Host: GitHub
- URL: https://github.com/geakstr/electron-watcher-webpack-plugin
- Owner: geakstr
- Created: 2019-02-04T19:30:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-03-24T07:10:02.000Z (over 4 years ago)
- Last Synced: 2025-03-11T04:43:22.782Z (over 1 year ago)
- Topics: electron, live-reload, livereload, plugin, watch, webpack, webpack-plugin
- Language: JavaScript
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## Installation
```shell
npm install electron-watcher-webpack-plugin --save
```
## Usage
Add to `webpack.config.js` plugins array:
```javascript
const path = require("path");
const { ElectronWatcherWebpackPlugin } = require("electron-watcher-webpack-plugin");
// ...
module.exports = {
// ...
plugins: [
// ...
new ElectronWatcherWebpackPlugin({
// Absolute path to directory where node_modules placed. Required
root: __dirname,
// List of globs to watch for hard reload. Required
watch: [path.resolve(__dirname, "./src/main")],
// Launch electron only once. Default: true. Optional
once: true,
// Absolute path to nodemon executable. Default: root/node_modules/.bin/nodemon. Optional
nodemon: path.resolve(__dirname, "node_modules", ".bin", "nodemon"),
// Absolute path to electron executable. Default: root/node_modules/.bin/electron. Optional
electron: path.resolve(__dirname, "node_modules", ".bin", "electron"),
// Options to pass to `spawn` process. Optional
options: {
cwd: path.resolve(__dirname, "..")
}
}),
// ...
];
// ...
}
```
And watch files changes inside `main.js`:
```javascript
const { app, BrowserWindow } = require("electron");
// ...
require("electron-watcher-webpack-plugin").watch({
// List of globs for hard refresh
hard: [path.resolve(__dirname, "../main")],
// List of globs for soft refresh
soft: [path.resolve(__dirname, "../renderer")]
// Watching enabled only in dev environment, but you can force watching anytime. Default: false. Optional
forceWatch: false
});
// ...
```