Skip to content

Commit

Permalink
Allow user to enable polling
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Mar 2, 2022
1 parent f77f1a7 commit 809cd3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cli.js
Expand Up @@ -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',
Expand All @@ -187,6 +188,7 @@ let commands = {
'-o': '--output',
'-m': '--minify',
'-w': '--watch',
'-p': '--poll',
},
},
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -751,6 +754,8 @@ async function build() {
}

watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
usePolling: shouldPoll,
interval: shouldPoll ? pollInterval : undefined,
ignoreInitial: true,
awaitWriteFinish: shouldCoalesceWriteEvents
? {
Expand Down

0 comments on commit 809cd3b

Please sign in to comment.