https://github.com/iceend/electron-watch
Automatically restart Electron app when the main process files are changed.
https://github.com/iceend/electron-watch
auto-reload electron electron-watch
Last synced: 9 months ago
JSON representation
Automatically restart Electron app when the main process files are changed.
- Host: GitHub
- URL: https://github.com/iceend/electron-watch
- Owner: IceEnd
- License: mit
- Created: 2018-01-26T03:10:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-13T02:07:17.000Z (over 5 years ago)
- Last Synced: 2025-04-14T13:41:08.755Z (about 1 year ago)
- Topics: auto-reload, electron, electron-watch
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-watch
> Automatically restart Electron app when the main process file is changed.
[](https://www.npmjs.com/package/electron-watch)
[](https://github.com/IceEnd/electron-watch/blob/master/LICENSE)
# Installation
```shell
npm install electron-watch
```
# Usage
For example,
`package.json`:
```js
{
//...
"scripts": {
"dev:electron-main": "cross-env NODE_ENV='development' electron -r babel-register ./app/renderer/",
},
//...
}
```
Adding code block to the main process file:
`index.js`:
```js
import electron from 'electron';
import path from 'path';
if (process.env.NODE_ENV === 'development') {
require('electron-watch')(
__dirname,
'dev:electron-main', // npm scripts, means: npm run dev:electron-main
path.join(__dirname, './'), // cwd
2000, // debounce delay
);
}
```
# OPTIONS
|field |type |description |
|----- |---- |---- |
|path |string |Paths to files, dirs to be watched recursively, or glob patterns.|
|command |string |`npm script` name, use this to start electron main process |
|cwd |string |Current working directory of the child process. |
|delay |Number |Delay (in ms) arguments of debounce, default is 3000ms |
# LICENSE
[MIT @ Alchemy](https://github.com/IceEnd/electron-watch/blob/master/LICENSE)