From f77f1a7270c669b6fbae7ac7b25bb9d5431339a5 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 2 Mar 2022 10:42:35 -0500 Subject: [PATCH 1/3] Refactor --- src/cli.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cli.js b/src/cli.js index 7f3fc8dd3d34..f18dd0ea07c6 100644 --- a/src/cli.js +++ b/src/cli.js @@ -367,8 +367,13 @@ async function build() { let input = args['--input'] let output = args['--output'] let shouldWatch = args['--watch'] + let shouldCoalesceWriteEvents = process.platform === 'win32' let includePostCss = args['--postcss'] + // Polling interval in milliseconds + // Used only when coalescing add/change events on Windows + let pollInterval = 10 + // TODO: Deprecate this in future versions if (!input && args['_'][1]) { console.error('[deprecation] Running tailwindcss without -i, please provide an input file.') @@ -747,13 +752,12 @@ async function build() { watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], { ignoreInitial: true, - awaitWriteFinish: - process.platform === 'win32' - ? { - stabilityThreshold: 50, - pollInterval: 10, - } - : false, + awaitWriteFinish: shouldCoalesceWriteEvents + ? { + stabilityThreshold: 50, + pollInterval: pollInterval, + } + : false, }) let chain = Promise.resolve() From 95c9016b48e227802da647f00893fa17d9a75f41 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 2 Mar 2022 10:42:50 -0500 Subject: [PATCH 2/3] Allow user to enable polling --- integrations/tailwindcss-cli/tests/cli.test.js | 1 + src/cli.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 ? { From d58fe64d31c0686ea9b6ae1a810077992b70b32b Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 2 Mar 2022 10:51:09 -0500 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d32a347b0ab0..e99e42066b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291)) - Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656)) - Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800)) +- Add `--poll` option to the CLI ([#7725](https://github.com/tailwindlabs/tailwindcss/pull/7725)) ## [3.0.23] - 2022-02-16