Skip to content

Commit

Permalink
fixes #1208: watchOptions not passed to chokidar in wds
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Dec 6, 2017
1 parent 6c1d3e4 commit f967925
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function Server(compiler, options) {
this.allowedHosts = options.allowedHosts;
this.sockets = [];
this.contentBaseWatchers = [];
this.watchOptions = options.watchOptions;

// Listening for events
const invalidPlugin = () => {
Expand Down Expand Up @@ -663,7 +664,24 @@ Server.prototype._sendStats = function (sockets, stats, force) {
};

Server.prototype._watch = function (watchPath) {
const watcher = chokidar.watch(watchPath).on('change', () => {
// duplicate the same massaging of options that watchpack performs
// https://github.com/webpack/watchpack/blob/master/lib/DirectoryWatcher.js#L49
// this isn't an elegant solution, but we'll improve it in the future
const usePolling = this.watchOptions.poll ? true : undefined; // eslint-disable-line no-undefined
const interval = typeof this.watchOptions.poll === 'number' ? this.watchOptions.poll : undefined; // eslint-disable-line no-undefined
const options = {
ignoreInitial: true,
persistent: true,
followSymlinks: false,
depth: 0,
atomic: false,
alwaysStat: true,
ignorePermissionErrors: true,
ignored: this.watchOptions.ignored,
usePolling,
interval
};
const watcher = chokidar.watch(watchPath, options).on('change', () => {
this.sockWrite(this.sockets, 'content-changed');
});

Expand Down

0 comments on commit f967925

Please sign in to comment.