# @michaelray/electron-reloader

> Simple auto-reloading for Electron apps during development

Latest version **0.0.0-a** (published 2021-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @michaelray/electron-reloader
pnpm add @michaelray/electron-reloader
yarn add @michaelray/electron-reloader
bun add @michaelray/electron-reloader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0-a |
| Published | 2021-08-29 |
| First published | 2021-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 586 |
| Author | Sindre Sorhus |
| Maintainers | michaelray1982 |
| Keywords | electron, reload, reloader, livereload, auto-reload, live-reload, refresh, restart, watch, watcher, watching, monitor, hot, files, fs, dev, development |

## Links

- npm: https://www.npmjs.com/package/@michaelray/electron-reloader
- Repository: https://github.com/sindresorhus/electron-reloader
- Homepage: https://github.com/sindresorhus/electron-reloader#readme
- Issues: https://github.com/sindresorhus/electron-reloader/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/@michaelray/electron-reloader

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [find-up](https://npm.io/package/find-up.md) ^5.0.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.5.0
- [date-time](https://npm.io/package/date-time.md) ^3.1.0
- [electron-is-dev](https://npm.io/package/electron-is-dev.md) ^1.2.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.0.0-a (latest) — 2021-08-29
- 0.0.0 — 2021-08-29

## README

# electron-reloader

> Simple auto-reloading for Electron apps during development

It *just works*. When files used in the main process are changed, the app is restarted, and when files used in the browser window are changed, the page is reloaded.

Note that it will not work correctly if you transpile the main process JS files of your app, but it doesn't make sense to do that anyway.

## Install

```
$ npm install --save-dev @michaelray/electron-reloader
```

*Requires Electron 5 or later.*

## Usage

The following must be included in the app entry file, usually named `index.js`:

```js
try {
	require('electron-reloader')(module,
		{
			ipcMain: [
				'/src/ipc-main/ipc-main.js',
				'/src/ipc-main/ipc-menu.js',
			],
		}
	);
} catch {}
```

You have to pass the `module` object so we can read the module graph and figure out which files belong to the main process.

The `try/catch` is needed so it doesn't throw `Cannot find module 'electron-reloader'` in production.

## API

### reloader(module, options?)

#### module

Type: `object`

The global `module` object.

#### options

Type: `object`

##### ignore

Type: `Array<string | RegExp>`

Ignore patterns passed to [`chokidar`](https://github.com/paulmillr/chokidar#path-filtering).

By default, files/directories starting with a `.`, `.map` files, and `node_modules` directories are ignored. This option is additive to those.

##### ipcMain

Type: `arrary`\
Default: `[]`

Watch ipcMain files in the ipc process when they change.
默认情况只检测入口文件，如果需要检测引入的主进程文件，请配置此项。

##### watchRenderer

Type: `boolean`\
Default: `true`

Watch files used in the renderer process and reload the window when they change.

Setting this to `false` can be useful if you use a different reload strategy in the rendererer process, like [`HMR`](https://webpack.js.org/concepts/hot-module-replacement/).

##### debug

Type: `boolean`\
Default: `false`

Prints watched paths and when files change.

Can be useful to make sure you set it up correctly.

## Tip

### Using it with Webpack watch mode

Just add the source directory to the `ignore` option. The dist directory is already watched, so when a source file changes, webpack will build it and output it to the dist directory, which this module will detect.

## Related

- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps and modules
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app
- [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app
- [electron-dl](https://github.com/sindresorhus/electron-dl) - Simplified file downloads for your Electron app
- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app
- [electron-serve](https://github.com/sindresorhus/electron-serve) - Static file serving for Electron apps

---
_Source: https://npm.io/package/@michaelray/electron-reloader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
