Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Nov 15, 2021
1 parent 7fa443a commit 9620eb1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/Server.js
Expand Up @@ -447,6 +447,10 @@ class Server {
const compilerWatchOptions = compilerOptions.watchOptions || {};

const getDefaultWatchOptions = (watchOptions = {}) => {
watchOptions = {
...compilerWatchOptions,
...watchOptions,
};
// 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
Expand All @@ -464,24 +468,23 @@ class Server {
: // eslint-disable-next-line no-undefined
undefined;

if (watchOptions.poll) {
delete watchOptions.poll;
}

const finalWatchOptions = {
ignoreInitial: true,
persistent: true,
followSymlinks: false,
atomic: false,
alwaysStat: true,
ignorePermissionErrors: true,
...compilerWatchOptions,
...watchOptions,
ignored: watchOptions.ignored,
usePolling,
interval,
};

if (finalWatchOptions.poll) {
delete finalWatchOptions.poll;
}

return finalWatchOptions;
};

Expand Down

0 comments on commit 9620eb1

Please sign in to comment.