From bb69168ae2981a519ecdc17357ab0aa1c903022e Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 2 Mar 2022 10:42:50 -0500 Subject: [PATCH] Allow user to enable polling --- src/cli.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index 3acbaa28ac38..bf3046c695ad 100644 --- a/src/cli.js +++ b/src/cli.js @@ -161,6 +161,7 @@ let commands = { '--input': { type: String, description: 'Input file' }, '--output': { type: String, description: 'Output file' }, '--watch': { type: Boolean, description: 'Watch for changes and rebuild as needed' }, + '--poll': { type: Boolean, description: 'Poll for changes every so often and rebuild' }, '--content': { type: String, description: 'Content paths to use for removing unused classes', @@ -187,6 +188,7 @@ let commands = { '-o': '--output', '-m': '--minify', '-w': '--watch', + '-p': '--poll', }, }, } @@ -367,11 +369,12 @@ async function build() { let input = args['--input'] let output = args['--output'] let shouldWatch = args['--watch'] - let shouldCoalesceWriteEvents = process.platform === 'win32' + let shouldPoll = args['--poll'] + let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32' let includePostCss = args['--postcss'] // Polling interval in milliseconds - // Used only when coalescing add/change events on Windows + // Used only when polling or coalescing add/change events on Windows let pollInterval = 10 // TODO: Deprecate this in future versions @@ -751,6 +754,8 @@ async function build() { } watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], { + usePolling: shouldPoll, + interval: shouldPoll ? pollInterval : undefined, ignoreInitial: true, awaitWriteFinish: shouldCoalesceWriteEvents