Skip to content

Commit 95c9016

Browse files
committed
Allow user to enable polling
1 parent f77f1a7 commit 95c9016

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

integrations/tailwindcss-cli/tests/cli.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ describe('Build command', () => {
291291
-i, --input Input file
292292
-o, --output Output file
293293
-w, --watch Watch for changes and rebuild as needed
294+
-p, --poll Use polling instead of filesystem events when watching
294295
--content Content paths to use for removing unused classes
295296
--postcss Load custom PostCSS configuration
296297
-m, --minify Minify the output

src/cli.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ let commands = {
161161
'--input': { type: String, description: 'Input file' },
162162
'--output': { type: String, description: 'Output file' },
163163
'--watch': { type: Boolean, description: 'Watch for changes and rebuild as needed' },
164+
'--poll': {
165+
type: Boolean,
166+
description: 'Use polling instead of filesystem events when watching',
167+
},
164168
'--content': {
165169
type: String,
166170
description: 'Content paths to use for removing unused classes',
@@ -187,6 +191,7 @@ let commands = {
187191
'-o': '--output',
188192
'-m': '--minify',
189193
'-w': '--watch',
194+
'-p': '--poll',
190195
},
191196
},
192197
}
@@ -367,11 +372,12 @@ async function build() {
367372
let input = args['--input']
368373
let output = args['--output']
369374
let shouldWatch = args['--watch']
370-
let shouldCoalesceWriteEvents = process.platform === 'win32'
375+
let shouldPoll = args['--poll']
376+
let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32'
371377
let includePostCss = args['--postcss']
372378

373379
// Polling interval in milliseconds
374-
// Used only when coalescing add/change events on Windows
380+
// Used only when polling or coalescing add/change events on Windows
375381
let pollInterval = 10
376382

377383
// TODO: Deprecate this in future versions
@@ -751,6 +757,8 @@ async function build() {
751757
}
752758

753759
watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
760+
usePolling: shouldPoll,
761+
interval: shouldPoll ? pollInterval : undefined,
754762
ignoreInitial: true,
755763
awaitWriteFinish: shouldCoalesceWriteEvents
756764
? {

0 commit comments

Comments
 (0)