tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +380 -1
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +311 -213
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +11 -1
  14. package/lib/corePlugins.js +1895 -1773
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +22 -16
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +156 -151
  26. package/lib/lib/generateRules.js +402 -68
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +45 -36
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +105 -90
  32. package/lib/lib/setupContextUtils.js +416 -291
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -15
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +21 -9
  40. package/lib/public/colors.js +244 -248
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +13 -17
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +35 -19
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +5 -3
  62. package/lib/util/normalizeConfig.js +233 -0
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +67 -170
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +123 -133
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +41 -42
  81. package/peers/index.js +11539 -10859
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/create-plugin-list.js +2 -2
  86. package/scripts/generate-types.js +52 -0
  87. package/src/cli-peer-dependencies.js +7 -1
  88. package/src/cli.js +174 -41
  89. package/src/corePluginList.js +1 -1
  90. package/src/corePlugins.js +641 -596
  91. package/src/css/preflight.css +19 -13
  92. package/src/featureFlags.js +16 -10
  93. package/src/index.js +14 -6
  94. package/src/lib/cacheInvalidation.js +52 -0
  95. package/src/lib/collapseAdjacentRules.js +21 -2
  96. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  97. package/src/lib/defaultExtractor.js +192 -0
  98. package/src/lib/detectNesting.js +22 -3
  99. package/src/lib/evaluateTailwindFunctions.js +24 -7
  100. package/src/lib/expandApplyAtRules.js +442 -154
  101. package/src/lib/expandTailwindAtRules.js +91 -65
  102. package/src/lib/generateRules.js +409 -43
  103. package/src/lib/normalizeTailwindDirectives.js +10 -3
  104. package/src/lib/partitionApplyAtRules.js +52 -0
  105. package/src/lib/regex.js +74 -0
  106. package/src/lib/resolveDefaultsAtRules.js +74 -53
  107. package/src/lib/setupContextUtils.js +388 -208
  108. package/src/lib/setupTrackingContext.js +15 -12
  109. package/src/lib/sharedState.js +42 -7
  110. package/src/lib/substituteScreenAtRules.js +6 -3
  111. package/src/postcss-plugins/nesting/README.md +42 -0
  112. package/src/postcss-plugins/nesting/index.js +13 -0
  113. package/src/postcss-plugins/nesting/plugin.js +80 -0
  114. package/src/processTailwindFeatures.js +17 -2
  115. package/src/public/colors.js +4 -9
  116. package/src/util/buildMediaQuery.js +14 -18
  117. package/src/util/cloneNodes.js +14 -1
  118. package/src/util/color.js +31 -14
  119. package/src/util/createUtilityPlugin.js +2 -2
  120. package/src/util/dataTypes.js +56 -16
  121. package/src/util/defaults.js +6 -0
  122. package/src/util/formatVariantSelector.js +213 -0
  123. package/src/util/getAllConfigs.js +7 -0
  124. package/src/util/isValidArbitraryValue.js +61 -0
  125. package/src/util/log.js +23 -22
  126. package/src/util/nameClass.js +2 -2
  127. package/src/util/negateValue.js +4 -2
  128. package/src/util/normalizeConfig.js +262 -0
  129. package/src/util/normalizeScreens.js +45 -0
  130. package/src/util/parseBoxShadowValue.js +72 -0
  131. package/src/util/pluginUtils.js +51 -147
  132. package/src/util/prefixSelector.js +7 -8
  133. package/src/util/resolveConfig.js +108 -79
  134. package/src/util/splitAtTopLevelOnly.js +71 -0
  135. package/src/util/toPath.js +23 -1
  136. package/src/util/transformThemeValue.js +24 -7
  137. package/src/util/validateConfig.js +13 -0
  138. package/stubs/defaultConfig.stub.js +157 -94
  139. package/stubs/simpleConfig.stub.js +0 -1
  140. package/types/config.d.ts +325 -0
  141. package/types/generated/.gitkeep +0 -0
  142. package/types/generated/colors.d.ts +276 -0
  143. package/types/generated/corePluginList.d.ts +1 -0
  144. package/types/index.d.ts +1 -0
  145. package/types.d.ts +1 -0
  146. package/lib/lib/setupWatchingContext.js +0 -284
  147. package/nesting/plugin.js +0 -41
  148. package/src/lib/setupWatchingContext.js +0 -306
package/plugin.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { Config, PluginCreator } from './types/config'
2
+ type Plugin = {
3
+ withOptions<T>(
4
+ plugin: (options: T) => PluginCreator,
5
+ config?: (options: T) => Config
6
+ ): { (options: T): { handler: PluginCreator; config?: Config }; __isOptionsFunction: true }
7
+ (plugin: PluginCreator, config?: Config): { handler: PluginCreator; config?: Config }
8
+ }
9
+
10
+ declare const plugin: Plugin
11
+ export = plugin
package/plugin.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/create-plugin').default
1
+ let createPlugin = require('./lib/public/create-plugin')
2
+ module.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default
package/resolveConfig.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/public/resolve-config').default
1
+ let resolveConfig = require('./lib/public/resolve-config')
2
+ module.exports = (resolveConfig.__esModule ? resolveConfig : { default: resolveConfig }).default
@@ -1,8 +1,8 @@
1
- import corePlugins from '../src/corePlugins'
1
+ import { corePlugins } from '../src/corePlugins'
2
2
  import fs from 'fs'
3
3
  import path from 'path'
4
4
 
5
- let corePluginList = Object.keys(corePlugins).filter((plugin) => !plugin.includes('Variants'))
5
+ let corePluginList = Object.keys(corePlugins)
6
6
 
7
7
  fs.writeFileSync(
8
8
  path.join(process.cwd(), 'src', 'corePluginList.js'),
@@ -0,0 +1,52 @@
1
+ import prettier from 'prettier'
2
+ import { corePlugins } from '../src/corePlugins'
3
+ import colors from '../src/public/colors'
4
+ import fs from 'fs'
5
+ import path from 'path'
6
+
7
+ fs.writeFileSync(
8
+ path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
9
+ `export type CorePluginList = ${Object.keys(corePlugins)
10
+ .map((p) => `'${p}'`)
11
+ .join(' | ')}`
12
+ )
13
+
14
+ let colorsWithoutDeprecatedColors = Object.fromEntries(
15
+ Object.entries(Object.getOwnPropertyDescriptors(colors))
16
+ .filter(([_, { value }]) => {
17
+ return typeof value !== 'undefined'
18
+ })
19
+ .map(([name, definition]) => [name, definition.value])
20
+ )
21
+
22
+ let deprecatedColors = Object.entries(Object.getOwnPropertyDescriptors(colors))
23
+ .filter(([_, { value }]) => {
24
+ return typeof value === 'undefined'
25
+ })
26
+ .map(([name, definition]) => {
27
+ let warn = console.warn
28
+ let messages = []
29
+ console.warn = (...args) => messages.push(args.pop())
30
+ definition.get()
31
+ console.warn = warn
32
+ let message = messages.join(' ').trim()
33
+ let newColor = message.match(/renamed to `(.*)`/)[1]
34
+ return `/** @deprecated ${message} */${name}: DefaultColors['${newColor}'],`
35
+ })
36
+ .join('\n')
37
+
38
+ fs.writeFileSync(
39
+ path.join(process.cwd(), 'types', 'generated', 'colors.d.ts'),
40
+ prettier.format(
41
+ `export interface DefaultColors { ${JSON.stringify(colorsWithoutDeprecatedColors).slice(
42
+ 1,
43
+ -1
44
+ )}\n${deprecatedColors}\n}`,
45
+ {
46
+ semi: false,
47
+ singleQuote: true,
48
+ printWidth: 100,
49
+ parser: 'typescript',
50
+ }
51
+ )
52
+ )
@@ -1,4 +1,10 @@
1
- export let postcss = require('postcss')
1
+ export function lazyPostcss() {
2
+ return require('postcss')
3
+ }
4
+
5
+ export function lazyPostcssImport() {
6
+ return require('postcss-import')
7
+ }
2
8
 
3
9
  export function lazyAutoprefixer() {
4
10
  return require('autoprefixer')
package/src/cli.js CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { postcss, lazyCssnano, lazyAutoprefixer } from '../peers/index.js'
3
+ import { lazyPostcss, lazyPostcssImport, lazyCssnano, lazyAutoprefixer } from '../peers/index.js'
4
4
 
5
5
  import chokidar from 'chokidar'
6
6
  import path from 'path'
7
7
  import arg from 'arg'
8
8
  import fs from 'fs'
9
9
  import postcssrc from 'postcss-load-config'
10
- import { cosmiconfig } from 'cosmiconfig'
10
+ import { lilconfig } from 'lilconfig'
11
11
  import loadPlugins from 'postcss-load-config/src/plugins' // Little bit scary, looking at private/internal API
12
+ import loadOptions from 'postcss-load-config/src/options' // Little bit scary, looking at private/internal API
12
13
  import tailwind from './processTailwindFeatures'
13
14
  import resolveConfigInternal from '../resolveConfig'
14
15
  import fastGlob from 'fast-glob'
@@ -16,11 +17,33 @@ import getModuleDependencies from './lib/getModuleDependencies'
16
17
  import log from './util/log'
17
18
  import packageJson from '../package.json'
18
19
  import normalizePath from 'normalize-path'
20
+ import { validateConfig } from './util/validateConfig.js'
19
21
 
20
22
  let env = {
21
- DEBUG: process.env.DEBUG !== undefined,
23
+ DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
22
24
  }
23
25
 
26
+ function isESM() {
27
+ const pkgPath = path.resolve('./package.json')
28
+
29
+ try {
30
+ let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
31
+ return pkg.type && pkg.type === 'module'
32
+ } catch (err) {
33
+ return false
34
+ }
35
+ }
36
+
37
+ let configs = isESM()
38
+ ? {
39
+ tailwind: 'tailwind.config.cjs',
40
+ postcss: 'postcss.config.cjs',
41
+ }
42
+ : {
43
+ tailwind: 'tailwind.config.js',
44
+ postcss: 'postcss.config.js',
45
+ }
46
+
24
47
  // ---
25
48
 
26
49
  function indentRecursive(node, indent = 0) {
@@ -41,6 +64,26 @@ function formatNodes(root) {
41
64
  }
42
65
  }
43
66
 
67
+ async function outputFile(file, contents) {
68
+ if (fs.existsSync(file) && (await fs.promises.readFile(file, 'utf8')) === contents) {
69
+ return // Skip writing the file
70
+ }
71
+
72
+ // Write the file
73
+ await fs.promises.writeFile(file, contents, 'utf8')
74
+ }
75
+
76
+ function drainStdin() {
77
+ return new Promise((resolve, reject) => {
78
+ let result = ''
79
+ process.stdin.on('data', (chunk) => {
80
+ result += chunk
81
+ })
82
+ process.stdin.on('end', () => resolve(result))
83
+ process.stdin.on('error', (err) => reject(err))
84
+ })
85
+ }
86
+
44
87
  function help({ message, usage, commands, options }) {
45
88
  let indent = 2
46
89
 
@@ -125,12 +168,25 @@ function oneOf(...options) {
125
168
  )
126
169
  }
127
170
 
171
+ function loadPostcss() {
172
+ // Try to load a local `postcss` version first
173
+ try {
174
+ return require('postcss')
175
+ } catch {}
176
+
177
+ return lazyPostcss()
178
+ }
179
+
128
180
  let commands = {
129
181
  init: {
130
182
  run: init,
131
183
  args: {
132
- '--full': { type: Boolean, description: 'Initialize a full `tailwind.config.js` file' },
133
- '--postcss': { type: Boolean, description: 'Initialize a `postcss.config.js` file' },
184
+ '--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
185
+ '--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
186
+ '--types': {
187
+ type: Boolean,
188
+ description: `Add TypeScript types for the \`${configs.tailwind}\` file`,
189
+ },
134
190
  '-f': '--full',
135
191
  '-p': '--postcss',
136
192
  },
@@ -141,6 +197,10 @@ let commands = {
141
197
  '--input': { type: String, description: 'Input file' },
142
198
  '--output': { type: String, description: 'Output file' },
143
199
  '--watch': { type: Boolean, description: 'Watch for changes and rebuild as needed' },
200
+ '--poll': {
201
+ type: Boolean,
202
+ description: 'Use polling instead of filesystem events when watching',
203
+ },
144
204
  '--content': {
145
205
  type: String,
146
206
  description: 'Content paths to use for removing unused classes',
@@ -167,6 +227,7 @@ let commands = {
167
227
  '-o': '--output',
168
228
  '-m': '--minify',
169
229
  '-w': '--watch',
230
+ '-p': '--poll',
170
231
  },
171
232
  },
172
233
  }
@@ -184,7 +245,7 @@ if (
184
245
  help({
185
246
  usage: [
186
247
  'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
187
- 'tailwindcss init [--full] [--postcss] [options...]',
248
+ 'tailwindcss init [--full] [--postcss] [--types] [options...]',
188
249
  ],
189
250
  commands: Object.keys(commands)
190
251
  .filter((command) => command !== 'build')
@@ -300,7 +361,7 @@ run()
300
361
  function init() {
301
362
  let messages = []
302
363
 
303
- let tailwindConfigLocation = path.resolve(args['_'][1] ?? './tailwind.config.js')
364
+ let tailwindConfigLocation = path.resolve(args['_'][1] ?? `./${configs.tailwind}`)
304
365
  if (fs.existsSync(tailwindConfigLocation)) {
305
366
  messages.push(`${path.basename(tailwindConfigLocation)} already exists.`)
306
367
  } else {
@@ -311,6 +372,13 @@ function init() {
311
372
  'utf8'
312
373
  )
313
374
 
375
+ if (args['--types']) {
376
+ let typesHeading = "/** @type {import('tailwindcss/types').Config} */"
377
+ stubFile =
378
+ stubFile.replace(`module.exports = `, `${typesHeading}\nconst config = `) +
379
+ '\nmodule.exports = config'
380
+ }
381
+
314
382
  // Change colors import
315
383
  stubFile = stubFile.replace('../colors', 'tailwindcss/colors')
316
384
 
@@ -320,7 +388,7 @@ function init() {
320
388
  }
321
389
 
322
390
  if (args['--postcss']) {
323
- let postcssConfigLocation = path.resolve('./postcss.config.js')
391
+ let postcssConfigLocation = path.resolve(`./${configs.postcss}`)
324
392
  if (fs.existsSync(postcssConfigLocation)) {
325
393
  messages.push(`${path.basename(postcssConfigLocation)} already exists.`)
326
394
  } else {
@@ -347,15 +415,21 @@ async function build() {
347
415
  let input = args['--input']
348
416
  let output = args['--output']
349
417
  let shouldWatch = args['--watch']
418
+ let shouldPoll = args['--poll']
419
+ let shouldCoalesceWriteEvents = shouldPoll || process.platform === 'win32'
350
420
  let includePostCss = args['--postcss']
351
421
 
422
+ // Polling interval in milliseconds
423
+ // Used only when polling or coalescing add/change events on Windows
424
+ let pollInterval = 10
425
+
352
426
  // TODO: Deprecate this in future versions
353
427
  if (!input && args['_'][1]) {
354
428
  console.error('[deprecation] Running tailwindcss without -i, please provide an input file.')
355
429
  input = args['--input'] = args['_'][1]
356
430
  }
357
431
 
358
- if (input && !fs.existsSync((input = path.resolve(input)))) {
432
+ if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
359
433
  console.error(`Specified input file ${args['--input']} does not exist.`)
360
434
  process.exit(9)
361
435
  }
@@ -368,17 +442,17 @@ async function build() {
368
442
  let configPath = args['--config']
369
443
  ? args['--config']
370
444
  : ((defaultPath) => (fs.existsSync(defaultPath) ? defaultPath : null))(
371
- path.resolve('./tailwind.config.js')
445
+ path.resolve(`./${configs.tailwind}`)
372
446
  )
373
447
 
374
448
  async function loadPostCssPlugins() {
375
449
  let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined
376
- let { plugins: configPlugins } = customPostCssPath
450
+ let config = customPostCssPath
377
451
  ? await (async () => {
378
452
  let file = path.resolve(customPostCssPath)
379
453
 
380
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
381
- let { config = {} } = await cosmiconfig('postcss').load(file)
454
+ // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
455
+ let { config = {} } = await lilconfig('postcss').load(file)
382
456
  if (typeof config === 'function') {
383
457
  config = config()
384
458
  } else {
@@ -389,10 +463,16 @@ async function build() {
389
463
  config.plugins = []
390
464
  }
391
465
 
392
- return { plugins: loadPlugins(config, file) }
466
+ return {
467
+ file,
468
+ plugins: loadPlugins(config, file),
469
+ options: loadOptions(config, file),
470
+ }
393
471
  })()
394
472
  : await postcssrc()
395
473
 
474
+ let configPlugins = config.plugins
475
+
396
476
  let configPluginTailwindIdx = configPlugins.findIndex((plugin) => {
397
477
  if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
398
478
  return true
@@ -412,33 +492,37 @@ async function build() {
412
492
  ? configPlugins
413
493
  : configPlugins.slice(configPluginTailwindIdx + 1)
414
494
 
415
- return [beforePlugins, afterPlugins]
495
+ return [beforePlugins, afterPlugins, config.options]
416
496
  }
417
497
 
418
498
  function resolveConfig() {
419
499
  let config = configPath ? require(configPath) : {}
420
- let resolvedConfig = resolveConfigInternal(config)
421
500
 
422
501
  if (args['--purge']) {
423
- log.warn(['The `--purge` flag has been deprecated.', 'Please use `--content` instead.'])
502
+ log.warn('purge-flag-deprecated', [
503
+ 'The `--purge` flag has been deprecated.',
504
+ 'Please use `--content` instead.',
505
+ ])
424
506
  if (!args['--content']) {
425
- args['--content'] = ['--purge']
507
+ args['--content'] = args['--purge']
426
508
  }
427
509
  }
428
510
 
429
511
  if (args['--content']) {
430
- resolvedConfig.content = args['--content'].split(/(?<!{[^}]+),/)
512
+ let files = args['--content'].split(/(?<!{[^}]+),/)
513
+ let resolvedConfig = resolveConfigInternal(config, { content: { files } })
514
+ resolvedConfig.content.files = files
515
+ resolvedConfig = validateConfig(resolvedConfig)
516
+ return resolvedConfig
431
517
  }
432
518
 
519
+ let resolvedConfig = resolveConfigInternal(config)
520
+ resolvedConfig = validateConfig(resolvedConfig)
433
521
  return resolvedConfig
434
522
  }
435
523
 
436
- function extractContent(config) {
437
- return config.content.content.concat(config.content.safelist)
438
- }
439
-
440
524
  function extractFileGlobs(config) {
441
- return extractContent(config)
525
+ return config.content.files
442
526
  .filter((file) => {
443
527
  // Strings in this case are files / globs. If it is something else,
444
528
  // like an object it's probably a raw content object. But this object
@@ -449,7 +533,7 @@ async function build() {
449
533
  }
450
534
 
451
535
  function extractRawContent(config) {
452
- return extractContent(config).filter((file) => {
536
+ return config.content.files.filter((file) => {
453
537
  return typeof file === 'object' && file !== null
454
538
  })
455
539
  }
@@ -464,7 +548,7 @@ async function build() {
464
548
  for (let file of files) {
465
549
  changedContent.push({
466
550
  content: fs.readFileSync(path.resolve(file), 'utf8'),
467
- extension: path.extname(file),
551
+ extension: path.extname(file).slice(1),
468
552
  })
469
553
  }
470
554
 
@@ -495,7 +579,21 @@ async function build() {
495
579
 
496
580
  tailwindPlugin.postcss = true
497
581
 
498
- let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [[], []]
582
+ let [beforePlugins, afterPlugins, postcssOptions] = includePostCss
583
+ ? await loadPostCssPlugins()
584
+ : [
585
+ [
586
+ (() => {
587
+ try {
588
+ return require('postcss-import')
589
+ } catch {}
590
+
591
+ return lazyPostcssImport()
592
+ })(),
593
+ ],
594
+ [],
595
+ {},
596
+ ]
499
597
 
500
598
  let plugins = [
501
599
  ...beforePlugins,
@@ -524,21 +622,23 @@ async function build() {
524
622
  })(),
525
623
  ].filter(Boolean)
526
624
 
625
+ let postcss = loadPostcss()
527
626
  let processor = postcss(plugins)
528
627
 
529
628
  function processCSS(css) {
530
629
  let start = process.hrtime.bigint()
531
630
  return Promise.resolve()
532
631
  .then(() => (output ? fs.promises.mkdir(path.dirname(output), { recursive: true }) : null))
533
- .then(() => processor.process(css, { from: input, to: output }))
632
+ .then(() => processor.process(css, { ...postcssOptions, from: input, to: output }))
534
633
  .then((result) => {
535
634
  if (!output) {
536
635
  return process.stdout.write(result.css)
537
636
  }
637
+
538
638
  return Promise.all(
539
639
  [
540
- fs.promises.writeFile(output, result.css, () => true),
541
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
640
+ outputFile(output, result.css),
641
+ result.map && outputFile(output + '.map', result.map.toString()),
542
642
  ].filter(Boolean)
543
643
  )
544
644
  })
@@ -549,9 +649,21 @@ async function build() {
549
649
  })
550
650
  }
551
651
 
552
- let css = input
553
- ? fs.readFileSync(path.resolve(input), 'utf8')
554
- : '@tailwind base; @tailwind components; @tailwind utilities'
652
+ let css = await (() => {
653
+ // Piping in data, let's drain the stdin
654
+ if (input === '-') {
655
+ return drainStdin()
656
+ }
657
+
658
+ // Input file has been provided
659
+ if (input) {
660
+ return fs.readFileSync(path.resolve(input), 'utf8')
661
+ }
662
+
663
+ // No input file provided, fallback to default atrules
664
+ return '@tailwind base; @tailwind components; @tailwind utilities'
665
+ })()
666
+
555
667
  return processCSS(css)
556
668
  }
557
669
 
@@ -644,6 +756,7 @@ async function build() {
644
756
  let tailwindPluginIdx = plugins.indexOf('__TAILWIND_PLUGIN_POSITION__')
645
757
  let copy = plugins.slice()
646
758
  copy.splice(tailwindPluginIdx, 1, tailwindPlugin)
759
+ let postcss = loadPostcss()
647
760
  let processor = postcss(copy)
648
761
 
649
762
  function processCSS(css) {
@@ -665,10 +778,10 @@ async function build() {
665
778
  return process.stdout.write(result.css)
666
779
  }
667
780
 
668
- await Promise.all(
781
+ return Promise.all(
669
782
  [
670
- fs.promises.writeFile(output, result.css, () => true),
671
- result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
783
+ outputFile(output, result.css),
784
+ result.map && outputFile(output + '.map', result.map.toString()),
672
785
  ].filter(Boolean)
673
786
  )
674
787
  })
@@ -685,9 +798,21 @@ async function build() {
685
798
  })
686
799
  }
687
800
 
688
- let css = input
689
- ? fs.readFileSync(path.resolve(input), 'utf8')
690
- : '@tailwind base; @tailwind components; @tailwind utilities'
801
+ let css = await (() => {
802
+ // Piping in data, let's drain the stdin
803
+ if (input === '-') {
804
+ return drainStdin()
805
+ }
806
+
807
+ // Input file has been provided
808
+ if (input) {
809
+ return fs.readFileSync(path.resolve(input), 'utf8')
810
+ }
811
+
812
+ // No input file provided, fallback to default atrules
813
+ return '@tailwind base; @tailwind components; @tailwind utilities'
814
+ })()
815
+
691
816
  let result = await processCSS(css)
692
817
  env.DEBUG && console.timeEnd('Finished in')
693
818
  return result
@@ -700,7 +825,15 @@ async function build() {
700
825
  }
701
826
 
702
827
  watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
828
+ usePolling: shouldPoll,
829
+ interval: shouldPoll ? pollInterval : undefined,
703
830
  ignoreInitial: true,
831
+ awaitWriteFinish: shouldCoalesceWriteEvents
832
+ ? {
833
+ stabilityThreshold: 50,
834
+ pollInterval: pollInterval,
835
+ }
836
+ : false,
704
837
  })
705
838
 
706
839
  let chain = Promise.resolve()
@@ -726,7 +859,7 @@ async function build() {
726
859
  chain = chain.then(async () => {
727
860
  changedContent.push({
728
861
  content: fs.readFileSync(path.resolve(file), 'utf8'),
729
- extension: path.extname(file),
862
+ extension: path.extname(file).slice(1),
730
863
  })
731
864
 
732
865
  await rebuild(config)
@@ -738,7 +871,7 @@ async function build() {
738
871
  chain = chain.then(async () => {
739
872
  changedContent.push({
740
873
  content: fs.readFileSync(path.resolve(file), 'utf8'),
741
- extension: path.extname(file),
874
+ extension: path.extname(file).slice(1),
742
875
  })
743
876
 
744
877
  await rebuild(config)
@@ -1 +1 @@
1
- export default ["preflight","container","accessibility","pointerEvents","visibility","position","inset","isolation","zIndex","order","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","float","clear","margin","boxSizing","display","aspectRatio","height","maxHeight","minHeight","width","minWidth","maxWidth","flex","flexShrink","flexGrow","tableLayout","borderCollapse","transformOrigin","translate","rotate","skew","scale","transform","animation","cursor","touchAction","userSelect","resize","scrollSnapType","scrollSnapAlign","scrollSnapStop","scrollMargin","scrollPadding","listStylePosition","listStyleType","appearance","columns","breakBefore","breakInside","breakAfter","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplateColumns","gridTemplateRows","flexDirection","flexWrap","placeContent","placeItems","alignContent","alignItems","justifyContent","justifyItems","gap","space","divideWidth","divideStyle","divideColor","divideOpacity","placeSelf","alignSelf","justifySelf","overflow","overscrollBehavior","scrollBehavior","textOverflow","whitespace","wordBreak","borderRadius","borderWidth","borderStyle","borderColor","borderOpacity","backgroundColor","backgroundOpacity","backgroundImage","gradientColorStops","boxDecorationBreak","backgroundSize","backgroundAttachment","backgroundClip","backgroundPosition","backgroundRepeat","backgroundOrigin","fill","stroke","strokeWidth","objectFit","objectPosition","padding","textAlign","textIndent","verticalAlign","fontFamily","fontSize","fontWeight","textTransform","fontStyle","fontVariantNumeric","lineHeight","letterSpacing","textColor","textOpacity","textDecoration","fontSmoothing","placeholderColor","placeholderOpacity","caretColor","accentColor","opacity","backgroundBlendMode","mixBlendMode","boxShadow","outline","ringWidth","ringColor","ringOpacity","ringOffsetWidth","ringOffsetColor","blur","brightness","contrast","dropShadow","grayscale","hueRotate","invert","saturate","sepia","filter","backdropBlur","backdropBrightness","backdropContrast","backdropGrayscale","backdropHueRotate","backdropInvert","backdropOpacity","backdropSaturate","backdropSepia","backdropFilter","transitionProperty","transitionDelay","transitionDuration","transitionTimingFunction","willChange","content"]
1
+ export default ["preflight","container","accessibility","pointerEvents","visibility","position","inset","isolation","zIndex","order","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","float","clear","margin","boxSizing","display","aspectRatio","height","maxHeight","minHeight","width","minWidth","maxWidth","flex","flexShrink","flexGrow","flexBasis","tableLayout","borderCollapse","borderSpacing","transformOrigin","translate","rotate","skew","scale","transform","animation","cursor","touchAction","userSelect","resize","scrollSnapType","scrollSnapAlign","scrollSnapStop","scrollMargin","scrollPadding","listStylePosition","listStyleType","appearance","columns","breakBefore","breakInside","breakAfter","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplateColumns","gridTemplateRows","flexDirection","flexWrap","placeContent","placeItems","alignContent","alignItems","justifyContent","justifyItems","gap","space","divideWidth","divideStyle","divideColor","divideOpacity","placeSelf","alignSelf","justifySelf","overflow","overscrollBehavior","scrollBehavior","textOverflow","whitespace","wordBreak","borderRadius","borderWidth","borderStyle","borderColor","borderOpacity","backgroundColor","backgroundOpacity","backgroundImage","gradientColorStops","boxDecorationBreak","backgroundSize","backgroundAttachment","backgroundClip","backgroundPosition","backgroundRepeat","backgroundOrigin","fill","stroke","strokeWidth","objectFit","objectPosition","padding","textAlign","textIndent","verticalAlign","fontFamily","fontSize","fontWeight","textTransform","fontStyle","fontVariantNumeric","lineHeight","letterSpacing","textColor","textOpacity","textDecoration","textDecorationColor","textDecorationStyle","textDecorationThickness","textUnderlineOffset","fontSmoothing","placeholderColor","placeholderOpacity","caretColor","accentColor","opacity","backgroundBlendMode","mixBlendMode","boxShadow","boxShadowColor","outlineStyle","outlineWidth","outlineOffset","outlineColor","ringWidth","ringColor","ringOpacity","ringOffsetWidth","ringOffsetColor","blur","brightness","contrast","dropShadow","grayscale","hueRotate","invert","saturate","sepia","filter","backdropBlur","backdropBrightness","backdropContrast","backdropGrayscale","backdropHueRotate","backdropInvert","backdropOpacity","backdropSaturate","backdropSepia","backdropFilter","transitionProperty","transitionDelay","transitionDuration","transitionTimingFunction","willChange","content"]