Skip to content

Commit

Permalink
Add watchRenderer option
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 29, 2018
1 parent 3d780a4 commit f8f556d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Expand Up @@ -24,7 +24,7 @@ function getMainProcessPaths(topModuleObj) {
return paths;
}

module.exports = (moduleObj, options = {}) => {
module.exports = (moduleObj, options) => {
// This module should be a dev dependency, but guard
// this in case the user included it as a dependency
if (!isDev) {
Expand All @@ -35,10 +35,15 @@ module.exports = (moduleObj, options = {}) => {
throw new Error('You have to pass the `module` object');
}

options = Object.assign({
watchRenderer: true
}, options);

const cwd = path.dirname(moduleObj.filename);
const mainProcessPaths = getMainProcessPaths(moduleObj);
const watchPaths = options.watchRenderer ? cwd : [...mainProcessPaths];

const watcher = chokidar.watch(cwd, {
const watcher = chokidar.watch(watchPaths, {
cwd,
disableGlobbing: true,
ignored: [
Expand Down
9 changes: 9 additions & 0 deletions readme.md
Expand Up @@ -56,6 +56,15 @@ 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.

##### watchRenderer

Type: `boolean`<br>
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/).


## Tip

Expand Down

0 comments on commit f8f556d

Please sign in to comment.