Add an explicit --poll option to the CLI (#7725)
* Refactor * Allow user to enable polling * Update changelog
This commit is contained in:
parent
f6793628a8
commit
ee945bbea2
3 changed files with 21 additions and 7 deletions
26
src/cli.js
26
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,8 +372,14 @@ async function build() {
|
|||
let input = args['--input']
|
||||
let output = args['--output']
|
||||
let shouldWatch = args['--watch']
|
||||
let shouldPoll = args['--poll']
|
||||
let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32'
|
||||
let includePostCss = args['--postcss']
|
||||
|
||||
// Polling interval in milliseconds
|
||||
// Used only when polling or 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.')
|
||||
|
|
@ -746,14 +757,15 @@ async function build() {
|
|||
}
|
||||
|
||||
watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
|
||||
usePolling: shouldPoll,
|
||||
interval: shouldPoll ? pollInterval : undefined,
|
||||
ignoreInitial: true,
|
||||
awaitWriteFinish:
|
||||
process.platform === 'win32'
|
||||
? {
|
||||
stabilityThreshold: 50,
|
||||
pollInterval: 10,
|
||||
}
|
||||
: false,
|
||||
awaitWriteFinish: shouldCoalesceWriteEvents
|
||||
? {
|
||||
stabilityThreshold: 50,
|
||||
pollInterval: pollInterval,
|
||||
}
|
||||
: false,
|
||||
})
|
||||
|
||||
let chain = Promise.resolve()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue