diff --git a/integrations/tailwindcss-cli/tests/cli.test.js b/integrations/tailwindcss-cli/tests/cli.test.js index 0cafb4a7bde1..644ebf2267cd 100644 --- a/integrations/tailwindcss-cli/tests/cli.test.js +++ b/integrations/tailwindcss-cli/tests/cli.test.js @@ -291,6 +291,7 @@ describe('Build command', () => { -i, --input Input file -o, --output Output file -w, --watch Watch for changes and rebuild as needed + -p, --poll Use polling instead of filesystem events when watching --content Content paths to use for removing unused classes --postcss Load custom PostCSS configuration -m, --minify Minify the output diff --git a/src/cli.js b/src/cli.js index f18dd0ea07c6..8aee860a870f 100644 --- a/src/cli.js +++ b/src/cli.js @@ -161,6 +161,10 @@ 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: 'Use polling instead of filesystem events when watching', + }, '--content': { type: String, description: 'Content paths to use for removing unused classes', @@ -187,6 +191,7 @@ let commands = { '-o': '--output', '-m': '--minify', '-w': '--watch', + '-p': '--poll', }, }, } @@ -367,11 +372,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 +757,8 @@ async function build() { } watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], { + usePolling: shouldPoll, + interval: shouldPoll ? pollInterval : undefined, ignoreInitial: true, awaitWriteFinish: shouldCoalesceWriteEvents ? {