Skip to content

Commit f967925

Browse files
committed
fixes #1208: watchOptions not passed to chokidar in wds
1 parent 6c1d3e4 commit f967925

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/Server.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function Server(compiler, options) {
5050
this.allowedHosts = options.allowedHosts;
5151
this.sockets = [];
5252
this.contentBaseWatchers = [];
53+
this.watchOptions = options.watchOptions;
5354

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

665666
Server.prototype._watch = function (watchPath) {
666-
const watcher = chokidar.watch(watchPath).on('change', () => {
667+
// duplicate the same massaging of options that watchpack performs
668+
// https://github.com/webpack/watchpack/blob/master/lib/DirectoryWatcher.js#L49
669+
// this isn't an elegant solution, but we'll improve it in the future
670+
const usePolling = this.watchOptions.poll ? true : undefined; // eslint-disable-line no-undefined
671+
const interval = typeof this.watchOptions.poll === 'number' ? this.watchOptions.poll : undefined; // eslint-disable-line no-undefined
672+
const options = {
673+
ignoreInitial: true,
674+
persistent: true,
675+
followSymlinks: false,
676+
depth: 0,
677+
atomic: false,
678+
alwaysStat: true,
679+
ignorePermissionErrors: true,
680+
ignored: this.watchOptions.ignored,
681+
usePolling,
682+
interval
683+
};
684+
const watcher = chokidar.watch(watchPath, options).on('change', () => {
667685
this.sockWrite(this.sockets, 'content-changed');
668686
});
669687

0 commit comments

Comments
 (0)