tailwindcss 3.0.23 → 3.0.24

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 (89) hide show
  1. package/CHANGELOG.md +29 -3
  2. package/lib/cli-peer-dependencies.js +3 -3
  3. package/lib/cli.js +183 -161
  4. package/lib/constants.js +8 -8
  5. package/lib/corePlugins.js +1572 -1523
  6. package/lib/featureFlags.js +9 -9
  7. package/lib/index.js +19 -6
  8. package/lib/lib/cacheInvalidation.js +69 -0
  9. package/lib/lib/collapseAdjacentRules.js +26 -13
  10. package/lib/lib/collapseDuplicateDeclarations.js +1 -1
  11. package/lib/lib/defaultExtractor.js +6 -6
  12. package/lib/lib/detectNesting.js +9 -9
  13. package/lib/lib/evaluateTailwindFunctions.js +16 -16
  14. package/lib/lib/expandApplyAtRules.js +180 -27
  15. package/lib/lib/expandTailwindAtRules.js +132 -122
  16. package/lib/lib/generateRules.js +90 -72
  17. package/lib/lib/getModuleDependencies.js +14 -14
  18. package/lib/lib/normalizeTailwindDirectives.js +35 -35
  19. package/lib/lib/partitionApplyAtRules.js +7 -7
  20. package/lib/lib/resolveDefaultsAtRules.js +81 -77
  21. package/lib/lib/setupContextUtils.js +78 -87
  22. package/lib/lib/setupTrackingContext.js +57 -57
  23. package/lib/lib/sharedState.js +10 -8
  24. package/lib/lib/substituteScreenAtRules.js +2 -2
  25. package/lib/postcss-plugins/nesting/README.md +2 -2
  26. package/lib/postcss-plugins/nesting/index.js +1 -1
  27. package/lib/postcss-plugins/nesting/plugin.js +41 -9
  28. package/lib/processTailwindFeatures.js +7 -7
  29. package/lib/public/colors.js +241 -241
  30. package/lib/public/resolve-config.js +5 -5
  31. package/lib/util/buildMediaQuery.js +2 -2
  32. package/lib/util/cloneDeep.js +1 -1
  33. package/lib/util/cloneNodes.js +12 -1
  34. package/lib/util/color.js +21 -20
  35. package/lib/util/createUtilityPlugin.js +6 -6
  36. package/lib/util/dataTypes.js +77 -75
  37. package/lib/util/escapeClassName.js +5 -5
  38. package/lib/util/escapeCommas.js +1 -1
  39. package/lib/util/flattenColorPalette.js +2 -2
  40. package/lib/util/formatVariantSelector.js +19 -19
  41. package/lib/util/getAllConfigs.js +5 -5
  42. package/lib/util/hashConfig.js +5 -5
  43. package/lib/util/isKeyframeRule.js +1 -1
  44. package/lib/util/isPlainObject.js +1 -1
  45. package/lib/util/isValidArbitraryValue.js +27 -27
  46. package/lib/util/log.js +8 -8
  47. package/lib/util/nameClass.js +7 -7
  48. package/lib/util/negateValue.js +4 -4
  49. package/lib/util/normalizeConfig.js +39 -39
  50. package/lib/util/normalizeScreens.js +4 -4
  51. package/lib/util/parseAnimationValue.js +56 -56
  52. package/lib/util/parseBoxShadowValue.js +60 -20
  53. package/lib/util/parseDependency.js +32 -32
  54. package/lib/util/parseObjectStyles.js +6 -6
  55. package/lib/util/pluginUtils.js +9 -9
  56. package/lib/util/prefixSelector.js +1 -1
  57. package/lib/util/resolveConfig.js +28 -28
  58. package/lib/util/resolveConfigPath.js +16 -16
  59. package/lib/util/responsive.js +6 -6
  60. package/lib/util/toColorValue.js +1 -1
  61. package/lib/util/toPath.js +2 -2
  62. package/lib/util/transformThemeValue.js +27 -27
  63. package/lib/util/withAlphaVariable.js +19 -19
  64. package/package.json +24 -23
  65. package/peers/index.js +4777 -4831
  66. package/scripts/generate-types.js +52 -0
  67. package/src/cli.js +41 -11
  68. package/src/corePlugins.js +67 -5
  69. package/src/featureFlags.js +2 -2
  70. package/src/index.js +17 -1
  71. package/src/lib/cacheInvalidation.js +52 -0
  72. package/src/lib/collapseAdjacentRules.js +16 -1
  73. package/src/lib/defaultExtractor.js +4 -4
  74. package/src/lib/expandApplyAtRules.js +179 -6
  75. package/src/lib/expandTailwindAtRules.js +25 -5
  76. package/src/lib/generateRules.js +68 -46
  77. package/src/lib/resolveDefaultsAtRules.js +6 -2
  78. package/src/lib/setupContextUtils.js +25 -26
  79. package/src/lib/setupTrackingContext.js +3 -3
  80. package/src/lib/sharedState.js +1 -0
  81. package/src/postcss-plugins/nesting/README.md +2 -2
  82. package/src/postcss-plugins/nesting/plugin.js +36 -0
  83. package/src/util/cloneNodes.js +14 -1
  84. package/src/util/color.js +7 -5
  85. package/src/util/dataTypes.js +3 -1
  86. package/src/util/log.js +7 -7
  87. package/src/util/parseBoxShadowValue.js +50 -2
  88. package/src/util/resolveConfig.js +32 -0
  89. package/stubs/defaultConfig.stub.js +5 -0
package/lib/cli.js CHANGED
@@ -6,7 +6,7 @@ var _path = _interopRequireDefault(require("path"));
6
6
  var _arg = _interopRequireDefault(require("arg"));
7
7
  var _fs = _interopRequireDefault(require("fs"));
8
8
  var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
9
- var _cosmiconfig = require("cosmiconfig");
9
+ var _lilconfig = require("lilconfig");
10
10
  var _plugins // Little bit scary, looking at private/internal API
11
11
  = _interopRequireDefault(require("postcss-load-config/src/plugins"));
12
12
  var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
@@ -22,40 +22,40 @@ function _interopRequireDefault(obj) {
22
22
  };
23
23
  }
24
24
  let env = {
25
- DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0'
25
+ DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== "0"
26
26
  };
27
27
  // ---
28
28
  function indentRecursive(node, indent = 0) {
29
29
  node.each && node.each((child, i)=>{
30
- if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes('\n')) {
31
- child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
30
+ if (!child.raws.before || !child.raws.before.trim() || child.raws.before.includes("\n")) {
31
+ child.raws.before = `\n${node.type !== "rule" && i > 0 ? "\n" : ""}${" ".repeat(indent)}`;
32
32
  }
33
- child.raws.after = `\n${' '.repeat(indent)}`;
33
+ child.raws.after = `\n${" ".repeat(indent)}`;
34
34
  indentRecursive(child, indent + 1);
35
35
  });
36
36
  }
37
37
  function formatNodes(root) {
38
38
  indentRecursive(root);
39
39
  if (root.first) {
40
- root.first.raws.before = '';
40
+ root.first.raws.before = "";
41
41
  }
42
42
  }
43
43
  async function outputFile(file, contents) {
44
- if (_fs.default.existsSync(file) && await _fs.default.promises.readFile(file, 'utf8') === contents) {
44
+ if (_fs.default.existsSync(file) && await _fs.default.promises.readFile(file, "utf8") === contents) {
45
45
  return; // Skip writing the file
46
46
  }
47
47
  // Write the file
48
- await _fs.default.promises.writeFile(file, contents, 'utf8');
48
+ await _fs.default.promises.writeFile(file, contents, "utf8");
49
49
  }
50
50
  function drainStdin() {
51
51
  return new Promise((resolve, reject)=>{
52
- let result = '';
53
- process.stdin.on('data', (chunk)=>{
52
+ let result = "";
53
+ process.stdin.on("data", (chunk)=>{
54
54
  result += chunk;
55
55
  });
56
- process.stdin.on('end', ()=>resolve(result)
56
+ process.stdin.on("end", ()=>resolve(result)
57
57
  );
58
- process.stdin.on('error', (err)=>reject(err)
58
+ process.stdin.on("error", (err)=>reject(err)
59
59
  );
60
60
  });
61
61
  }
@@ -67,31 +67,31 @@ function help({ message , usage , commands: commands1 , options }) {
67
67
  // Render message
68
68
  if (message) {
69
69
  console.log();
70
- for (let msg of message.split('\n')){
70
+ for (let msg of message.split("\n")){
71
71
  console.log(msg);
72
72
  }
73
73
  }
74
74
  // Render usage
75
75
  if (usage && usage.length > 0) {
76
76
  console.log();
77
- console.log('Usage:');
77
+ console.log("Usage:");
78
78
  for (let example of usage){
79
- console.log(' '.repeat(indent), example);
79
+ console.log(" ".repeat(indent), example);
80
80
  }
81
81
  }
82
82
  // Render commands
83
83
  if (commands1 && commands1.length > 0) {
84
84
  console.log();
85
- console.log('Commands:');
85
+ console.log("Commands:");
86
86
  for (let command1 of commands1){
87
- console.log(' '.repeat(indent), command1);
87
+ console.log(" ".repeat(indent), command1);
88
88
  }
89
89
  }
90
90
  // Render options
91
91
  if (options) {
92
92
  let groupedOptions = {};
93
93
  for (let [key, value] of Object.entries(options)){
94
- if (typeof value === 'object') {
94
+ if (typeof value === "object") {
95
95
  groupedOptions[key] = {
96
96
  ...value,
97
97
  flags: [
@@ -103,13 +103,13 @@ function help({ message , usage , commands: commands1 , options }) {
103
103
  }
104
104
  }
105
105
  console.log();
106
- console.log('Options:');
106
+ console.log("Options:");
107
107
  for (let { flags: flags1 , description , deprecated } of Object.values(groupedOptions)){
108
108
  if (deprecated) continue;
109
109
  if (flags1.length === 1) {
110
- console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags1.slice().reverse().join(', ').padEnd(20, ' '), description);
110
+ console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags1.slice().reverse().join(", ").padEnd(20, " "), description);
111
111
  } else {
112
- console.log(' '.repeat(indent), flags1.slice().reverse().join(', ').padEnd(24, ' '), description);
112
+ console.log(" ".repeat(indent), flags1.slice().reverse().join(", ").padEnd(24, " "), description);
113
113
  }
114
114
  }
115
115
  }
@@ -123,7 +123,7 @@ function oneOf(...options) {
123
123
  return parsed;
124
124
  }
125
125
  }
126
- throw new Error('...');
126
+ throw new Error("...");
127
127
  }, {
128
128
  manualParsing: true
129
129
  });
@@ -132,80 +132,89 @@ let commands = {
132
132
  init: {
133
133
  run: init,
134
134
  args: {
135
- '--full': {
135
+ "--full": {
136
136
  type: Boolean,
137
- description: 'Initialize a full `tailwind.config.js` file'
137
+ description: "Initialize a full `tailwind.config.js` file"
138
138
  },
139
- '--postcss': {
139
+ "--postcss": {
140
140
  type: Boolean,
141
- description: 'Initialize a `postcss.config.js` file'
141
+ description: "Initialize a `postcss.config.js` file"
142
142
  },
143
- '-f': '--full',
144
- '-p': '--postcss'
143
+ "--types": {
144
+ type: Boolean,
145
+ description: "Add TypeScript types for the `tailwind.config.js` file"
146
+ },
147
+ "-f": "--full",
148
+ "-p": "--postcss"
145
149
  }
146
150
  },
147
151
  build: {
148
152
  run: build,
149
153
  args: {
150
- '--input': {
154
+ "--input": {
151
155
  type: String,
152
- description: 'Input file'
156
+ description: "Input file"
153
157
  },
154
- '--output': {
158
+ "--output": {
155
159
  type: String,
156
- description: 'Output file'
160
+ description: "Output file"
157
161
  },
158
- '--watch': {
162
+ "--watch": {
159
163
  type: Boolean,
160
- description: 'Watch for changes and rebuild as needed'
164
+ description: "Watch for changes and rebuild as needed"
161
165
  },
162
- '--content': {
166
+ /*
167
+ '--poll': {
168
+ type: Boolean,
169
+ description: 'Use polling instead of filesystem events when watching',
170
+ },
171
+ */ "--content": {
163
172
  type: String,
164
- description: 'Content paths to use for removing unused classes'
173
+ description: "Content paths to use for removing unused classes"
165
174
  },
166
- '--purge': {
175
+ "--purge": {
167
176
  type: String,
168
177
  deprecated: true
169
178
  },
170
- '--postcss': {
179
+ "--postcss": {
171
180
  type: oneOf(String, Boolean),
172
- description: 'Load custom PostCSS configuration'
181
+ description: "Load custom PostCSS configuration"
173
182
  },
174
- '--minify': {
183
+ "--minify": {
175
184
  type: Boolean,
176
- description: 'Minify the output'
185
+ description: "Minify the output"
177
186
  },
178
- '--config': {
187
+ "--config": {
179
188
  type: String,
180
- description: 'Path to a custom config file'
189
+ description: "Path to a custom config file"
181
190
  },
182
- '--no-autoprefixer': {
191
+ "--no-autoprefixer": {
183
192
  type: Boolean,
184
- description: 'Disable autoprefixer'
193
+ description: "Disable autoprefixer"
185
194
  },
186
- '-c': '--config',
187
- '-i': '--input',
188
- '-o': '--output',
189
- '-m': '--minify',
190
- '-w': '--watch'
195
+ "-c": "--config",
196
+ "-i": "--input",
197
+ "-o": "--output",
198
+ "-m": "--minify",
199
+ "-w": "--watch"
191
200
  }
192
201
  }
193
202
  };
194
203
  let sharedFlags = {
195
- '--help': {
204
+ "--help": {
196
205
  type: Boolean,
197
- description: 'Display usage information'
206
+ description: "Display usage information"
198
207
  },
199
- '-h': '--help'
208
+ "-h": "--help"
200
209
  };
201
210
  if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined
202
211
  ))) {
203
212
  help({
204
213
  usage: [
205
- 'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
206
- 'tailwindcss init [--full] [--postcss] [options...]',
214
+ "tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
215
+ "tailwindcss init [--full] [--postcss] [--types] [options...]",
207
216
  ],
208
- commands: Object.keys(commands).filter((command2)=>command2 !== 'build'
217
+ commands: Object.keys(commands).filter((command2)=>command2 !== "build"
209
218
  ).map((command3)=>`${command3} [options]`
210
219
  ),
211
220
  options: {
@@ -215,20 +224,20 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
215
224
  });
216
225
  process.exit(0);
217
226
  }
218
- let command = ((arg = '')=>arg.startsWith('-') ? undefined : arg
219
- )(process.argv[2]) || 'build';
227
+ let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg
228
+ )(process.argv[2]) || "build";
220
229
  if (commands[command] === undefined) {
221
230
  if (_fs.default.existsSync(_path.default.resolve(command))) {
222
231
  // TODO: Deprecate this in future versions
223
232
  // Check if non-existing command, might be a file.
224
- command = 'build';
233
+ command = "build";
225
234
  } else {
226
235
  help({
227
236
  message: `Invalid command: ${command}`,
228
237
  usage: [
229
- 'tailwindcss <command> [options]'
238
+ "tailwindcss <command> [options]"
230
239
  ],
231
- commands: Object.keys(commands).filter((command4)=>command4 !== 'build'
240
+ commands: Object.keys(commands).filter((command4)=>command4 !== "build"
232
241
  ).map((command5)=>`${command5} [options]`
233
242
  ),
234
243
  options: sharedFlags
@@ -248,19 +257,19 @@ let args = (()=>{
248
257
  return !(value === null || value === void 0 ? void 0 : (ref = value.type) === null || ref === void 0 ? void 0 : ref.manualParsing);
249
258
  }).map(([key, value])=>[
250
259
  key,
251
- typeof value === 'object' ? value.type : value
260
+ typeof value === "object" ? value.type : value
252
261
  ]
253
262
  )), {
254
263
  permissive: true
255
264
  });
256
265
  // Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
257
- for(let i = result['_'].length - 1; i >= 0; --i){
258
- let flag = result['_'][i];
259
- if (!flag.startsWith('-')) continue;
266
+ for(let i = result["_"].length - 1; i >= 0; --i){
267
+ let flag = result["_"][i];
268
+ if (!flag.startsWith("-")) continue;
260
269
  let flagName = flag;
261
270
  let handler = flags[flag];
262
271
  // Resolve flagName & handler
263
- while(typeof handler === 'string'){
272
+ while(typeof handler === "string"){
264
273
  flagName = handler;
265
274
  handler = flags[handler];
266
275
  }
@@ -268,11 +277,11 @@ let args = (()=>{
268
277
  let args1 = [];
269
278
  let offset = i + 1;
270
279
  // Parse args for current flag
271
- while(result['_'][offset] && !result['_'][offset].startsWith('-')){
272
- args1.push(result['_'][offset++]);
280
+ while(result["_"][offset] && !result["_"][offset].startsWith("-")){
281
+ args1.push(result["_"][offset++]);
273
282
  }
274
283
  // Cleanup manually parsed flags + args
275
- result['_'].splice(i, 1 + args1.length);
284
+ result["_"].splice(i, 1 + args1.length);
276
285
  // Set the resolved value in the `result` object
277
286
  result[flagName] = handler.type(args1.length === 0 ? undefined : args1.length === 1 ? args1[0] : args1, flagName);
278
287
  }
@@ -282,16 +291,16 @@ let args = (()=>{
282
291
  //
283
292
  // E.g.: tailwindcss input.css -> _: ['build', 'input.css']
284
293
  // E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
285
- if (result['_'][0] !== command) {
286
- result['_'].unshift(command);
294
+ if (result["_"][0] !== command) {
295
+ result["_"].unshift(command);
287
296
  }
288
297
  return result;
289
298
  } catch (err) {
290
- if (err.code === 'ARG_UNKNOWN_OPTION') {
299
+ if (err.code === "ARG_UNKNOWN_OPTION") {
291
300
  help({
292
301
  message: err.message,
293
302
  usage: [
294
- 'tailwindcss <command> [options]'
303
+ "tailwindcss <command> [options]"
295
304
  ],
296
305
  options: sharedFlags
297
306
  });
@@ -300,7 +309,7 @@ let args = (()=>{
300
309
  throw err;
301
310
  }
302
311
  })();
303
- if (args['--help']) {
312
+ if (args["--help"]) {
304
313
  help({
305
314
  options: {
306
315
  ...flags,
@@ -317,23 +326,27 @@ run();
317
326
  function init() {
318
327
  let messages = [];
319
328
  var ref;
320
- let tailwindConfigLocation = _path.default.resolve((ref = args['_'][1]) !== null && ref !== void 0 ? ref : './tailwind.config.js');
329
+ let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref : "./tailwind.config.js");
321
330
  if (_fs.default.existsSync(tailwindConfigLocation)) {
322
331
  messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
323
332
  } else {
324
- let stubFile = _fs.default.readFileSync(args['--full'] ? _path.default.resolve(__dirname, '../stubs/defaultConfig.stub.js') : _path.default.resolve(__dirname, '../stubs/simpleConfig.stub.js'), 'utf8');
333
+ let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../stubs/simpleConfig.stub.js"), "utf8");
334
+ if (args["--types"]) {
335
+ let typesHeading = "/** @type {import('tailwindcss/types').Config} */";
336
+ stubFile = stubFile.replace(`module.exports = `, `${typesHeading}\nconst config = `) + "\nmodule.exports = config";
337
+ }
325
338
  // Change colors import
326
- stubFile = stubFile.replace('../colors', 'tailwindcss/colors');
327
- _fs.default.writeFileSync(tailwindConfigLocation, stubFile, 'utf8');
339
+ stubFile = stubFile.replace("../colors", "tailwindcss/colors");
340
+ _fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
328
341
  messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
329
342
  }
330
- if (args['--postcss']) {
331
- let postcssConfigLocation = _path.default.resolve('./postcss.config.js');
343
+ if (args["--postcss"]) {
344
+ let postcssConfigLocation = _path.default.resolve("./postcss.config.js");
332
345
  if (_fs.default.existsSync(postcssConfigLocation)) {
333
346
  messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
334
347
  } else {
335
- let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, '../stubs/defaultPostCssConfig.stub.js'), 'utf8');
336
- _fs.default.writeFileSync(postcssConfigLocation, stubFile, 'utf8');
348
+ let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, "../stubs/defaultPostCssConfig.stub.js"), "utf8");
349
+ _fs.default.writeFileSync(postcssConfigLocation, stubFile, "utf8");
337
350
  messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
338
351
  }
339
352
  }
@@ -345,32 +358,39 @@ function init() {
345
358
  }
346
359
  }
347
360
  async function build() {
348
- let input = args['--input'];
349
- let output = args['--output'];
350
- let shouldWatch = args['--watch'];
351
- let includePostCss = args['--postcss'];
361
+ let input = args["--input"];
362
+ let output = args["--output"];
363
+ let shouldWatch = args["--watch"];
364
+ let shouldPoll = false;
365
+ /*
366
+ let shouldPoll = args['--poll']
367
+ */ let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
368
+ let includePostCss = args["--postcss"];
369
+ // Polling interval in milliseconds
370
+ // Used only when polling or coalescing add/change events on Windows
371
+ let pollInterval = 10;
352
372
  // TODO: Deprecate this in future versions
353
- if (!input && args['_'][1]) {
354
- console.error('[deprecation] Running tailwindcss without -i, please provide an input file.');
355
- input = args['--input'] = args['_'][1];
373
+ if (!input && args["_"][1]) {
374
+ console.error("[deprecation] Running tailwindcss without -i, please provide an input file.");
375
+ input = args["--input"] = args["_"][1];
356
376
  }
357
- if (input && input !== '-' && !_fs.default.existsSync(input = _path.default.resolve(input))) {
358
- console.error(`Specified input file ${args['--input']} does not exist.`);
377
+ if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
378
+ console.error(`Specified input file ${args["--input"]} does not exist.`);
359
379
  process.exit(9);
360
380
  }
361
- if (args['--config'] && !_fs.default.existsSync(args['--config'] = _path.default.resolve(args['--config']))) {
362
- console.error(`Specified config file ${args['--config']} does not exist.`);
381
+ if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
382
+ console.error(`Specified config file ${args["--config"]} does not exist.`);
363
383
  process.exit(9);
364
384
  }
365
- let configPath = args['--config'] ? args['--config'] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
366
- )(_path.default.resolve('./tailwind.config.js'));
385
+ let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
386
+ )(_path.default.resolve("./tailwind.config.js"));
367
387
  async function loadPostCssPlugins() {
368
- let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined;
388
+ let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
369
389
  let { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
370
390
  let file = _path.default.resolve(customPostCssPath);
371
- // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
372
- let { config ={} } = await (0, _cosmiconfig).cosmiconfig('postcss').load(file);
373
- if (typeof config === 'function') {
391
+ // Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
392
+ let { config ={} } = await (0, _lilconfig).lilconfig("postcss").load(file);
393
+ if (typeof config === "function") {
374
394
  config = config();
375
395
  } else {
376
396
  config = Object.assign({}, config);
@@ -383,10 +403,10 @@ async function build() {
383
403
  };
384
404
  })() : await (0, _postcssLoadConfig).default();
385
405
  let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
386
- if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
406
+ if (typeof plugin === "function" && plugin.name === "tailwindcss") {
387
407
  return true;
388
408
  }
389
- if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
409
+ if (typeof plugin === "object" && plugin !== null && plugin.postcssPlugin === "tailwindcss") {
390
410
  return true;
391
411
  }
392
412
  return false;
@@ -400,17 +420,17 @@ async function build() {
400
420
  }
401
421
  function resolveConfig() {
402
422
  let config = configPath ? require(configPath) : {};
403
- if (args['--purge']) {
404
- _log.default.warn('purge-flag-deprecated', [
405
- 'The `--purge` flag has been deprecated.',
406
- 'Please use `--content` instead.',
423
+ if (args["--purge"]) {
424
+ _log.default.warn("purge-flag-deprecated", [
425
+ "The `--purge` flag has been deprecated.",
426
+ "Please use `--content` instead.",
407
427
  ]);
408
- if (!args['--content']) {
409
- args['--content'] = args['--purge'];
428
+ if (!args["--content"]) {
429
+ args["--content"] = args["--purge"];
410
430
  }
411
431
  }
412
- if (args['--content']) {
413
- let files = args['--content'].split(/(?<!{[^}]+),/);
432
+ if (args["--content"]) {
433
+ let files = args["--content"].split(/(?<!{[^}]+),/);
414
434
  let resolvedConfig = (0, _resolveConfig).default(config, {
415
435
  content: {
416
436
  files
@@ -426,13 +446,13 @@ async function build() {
426
446
  // Strings in this case are files / globs. If it is something else,
427
447
  // like an object it's probably a raw content object. But this object
428
448
  // is not watchable, so let's remove it.
429
- return typeof file === 'string';
449
+ return typeof file === "string";
430
450
  }).map((glob)=>(0, _normalizePath).default(glob)
431
451
  );
432
452
  }
433
453
  function extractRawContent(config) {
434
454
  return config.content.files.filter((file)=>{
435
- return typeof file === 'object' && file !== null;
455
+ return typeof file === "object" && file !== null;
436
456
  });
437
457
  }
438
458
  function getChangedContent(config) {
@@ -442,12 +462,12 @@ async function build() {
442
462
  let files = _fastGlob.default.sync(globs);
443
463
  for (let file of files){
444
464
  changedContent.push({
445
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
465
+ content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
446
466
  extension: _path.default.extname(file).slice(1)
447
467
  });
448
468
  }
449
469
  // Resolve raw content in the tailwind config
450
- for (let { raw: content , extension ='html' } of extractRawContent(config)){
470
+ for (let { raw: content , extension ="html" } of extractRawContent(config)){
451
471
  changedContent.push({
452
472
  content,
453
473
  extension
@@ -460,7 +480,7 @@ async function build() {
460
480
  let changedContent = getChangedContent(config);
461
481
  let tailwindPlugin = ()=>{
462
482
  return {
463
- postcssPlugin: 'tailwindcss',
483
+ postcssPlugin: "tailwindcss",
464
484
  Once (root, { result }) {
465
485
  (0, _processTailwindFeatures).default(({ createContext })=>{
466
486
  return ()=>{
@@ -478,19 +498,19 @@ async function build() {
478
498
  let plugins = [
479
499
  ...beforePlugins,
480
500
  tailwindPlugin,
481
- !args['--minify'] && formatNodes,
501
+ !args["--minify"] && formatNodes,
482
502
  ...afterPlugins,
483
- !args['--no-autoprefixer'] && (()=>{
503
+ !args["--no-autoprefixer"] && (()=>{
484
504
  // Try to load a local `autoprefixer` version first
485
505
  try {
486
- return require('autoprefixer');
506
+ return require("autoprefixer");
487
507
  } catch {}
488
508
  return (0, _indexJs).lazyAutoprefixer();
489
509
  })(),
490
- args['--minify'] && (()=>{
510
+ args["--minify"] && (()=>{
491
511
  let options = {
492
512
  preset: [
493
- 'default',
513
+ "default",
494
514
  {
495
515
  cssDeclarationSorter: false
496
516
  }
@@ -498,7 +518,7 @@ async function build() {
498
518
  };
499
519
  // Try to load a local `cssnano` version first
500
520
  try {
501
- return require('cssnano');
521
+ return require("cssnano");
502
522
  } catch {}
503
523
  return (0, _indexJs).lazyCssnano()(options);
504
524
  })(),
@@ -519,25 +539,25 @@ async function build() {
519
539
  }
520
540
  return Promise.all([
521
541
  outputFile(output, result.css),
522
- result.map && outputFile(output + '.map', result.map.toString()),
542
+ result.map && outputFile(output + ".map", result.map.toString()),
523
543
  ].filter(Boolean));
524
544
  }).then(()=>{
525
545
  let end = process.hrtime.bigint();
526
546
  console.error();
527
- console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
547
+ console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
528
548
  });
529
549
  }
530
550
  let css1 = await (()=>{
531
551
  // Piping in data, let's drain the stdin
532
- if (input === '-') {
552
+ if (input === "-") {
533
553
  return drainStdin();
534
554
  }
535
555
  // Input file has been provided
536
556
  if (input) {
537
- return _fs.default.readFileSync(_path.default.resolve(input), 'utf8');
557
+ return _fs.default.readFileSync(_path.default.resolve(input), "utf8");
538
558
  }
539
559
  // No input file provided, fallback to default atrules
540
- return '@tailwind base; @tailwind components; @tailwind utilities';
560
+ return "@tailwind base; @tailwind components; @tailwind utilities";
541
561
  })();
542
562
  return processCSS(css1);
543
563
  }
@@ -548,7 +568,7 @@ async function build() {
548
568
  let contextDependencies = new Set();
549
569
  let watcher = null;
550
570
  function refreshConfig() {
551
- env.DEBUG && console.time('Module dependencies');
571
+ env.DEBUG && console.time("Module dependencies");
552
572
  for (let file1 of configDependencies){
553
573
  delete require.cache[require.resolve(file1)];
554
574
  }
@@ -559,7 +579,7 @@ async function build() {
559
579
  contextDependencies.add(dependency);
560
580
  }
561
581
  }
562
- env.DEBUG && console.timeEnd('Module dependencies');
582
+ env.DEBUG && console.timeEnd("Module dependencies");
563
583
  return resolveConfig();
564
584
  }
565
585
  let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
@@ -568,20 +588,20 @@ async function build() {
568
588
  ];
569
589
  let plugins = [
570
590
  ...beforePlugins,
571
- '__TAILWIND_PLUGIN_POSITION__',
572
- !args['--minify'] && formatNodes,
591
+ "__TAILWIND_PLUGIN_POSITION__",
592
+ !args["--minify"] && formatNodes,
573
593
  ...afterPlugins,
574
- !args['--no-autoprefixer'] && (()=>{
594
+ !args["--no-autoprefixer"] && (()=>{
575
595
  // Try to load a local `autoprefixer` version first
576
596
  try {
577
- return require('autoprefixer');
597
+ return require("autoprefixer");
578
598
  } catch {}
579
599
  return (0, _indexJs).lazyAutoprefixer();
580
600
  })(),
581
- args['--minify'] && (()=>{
601
+ args["--minify"] && (()=>{
582
602
  let options = {
583
603
  preset: [
584
- 'default',
604
+ "default",
585
605
  {
586
606
  cssDeclarationSorter: false
587
607
  }
@@ -589,38 +609,38 @@ async function build() {
589
609
  };
590
610
  // Try to load a local `cssnano` version first
591
611
  try {
592
- return require('cssnano');
612
+ return require("cssnano");
593
613
  } catch {}
594
614
  return (0, _indexJs).lazyCssnano()(options);
595
615
  })(),
596
616
  ].filter(Boolean);
597
617
  async function rebuild(config) {
598
- env.DEBUG && console.time('Finished in');
618
+ env.DEBUG && console.time("Finished in");
599
619
  let tailwindPlugin = ()=>{
600
620
  return {
601
- postcssPlugin: 'tailwindcss',
621
+ postcssPlugin: "tailwindcss",
602
622
  Once (root, { result }) {
603
- env.DEBUG && console.time('Compiling CSS');
623
+ env.DEBUG && console.time("Compiling CSS");
604
624
  (0, _processTailwindFeatures).default(({ createContext })=>{
605
625
  console.error();
606
- console.error('Rebuilding...');
626
+ console.error("Rebuilding...");
607
627
  return ()=>{
608
628
  if (context !== null) {
609
629
  context.changedContent = changedContent.splice(0);
610
630
  return context;
611
631
  }
612
- env.DEBUG && console.time('Creating context');
632
+ env.DEBUG && console.time("Creating context");
613
633
  context = createContext(config, changedContent.splice(0));
614
- env.DEBUG && console.timeEnd('Creating context');
634
+ env.DEBUG && console.timeEnd("Creating context");
615
635
  return context;
616
636
  };
617
637
  })(root, result);
618
- env.DEBUG && console.timeEnd('Compiling CSS');
638
+ env.DEBUG && console.timeEnd("Compiling CSS");
619
639
  }
620
640
  };
621
641
  };
622
642
  tailwindPlugin.postcss = true;
623
- let tailwindPluginIdx = plugins.indexOf('__TAILWIND_PLUGIN_POSITION__');
643
+ let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
624
644
  let copy = plugins.slice();
625
645
  copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
626
646
  let processor = (0, _indexJs).postcss(copy);
@@ -635,7 +655,7 @@ async function build() {
635
655
  })
636
656
  ).then(async (result)=>{
637
657
  for (let message of result.messages){
638
- if (message.type === 'dependency') {
658
+ if (message.type === "dependency") {
639
659
  contextDependencies.add(message.file);
640
660
  }
641
661
  }
@@ -647,13 +667,13 @@ async function build() {
647
667
  }
648
668
  return Promise.all([
649
669
  outputFile(output, result.css),
650
- result.map && outputFile(output + '.map', result.map.toString()),
670
+ result.map && outputFile(output + ".map", result.map.toString()),
651
671
  ].filter(Boolean));
652
672
  }).then(()=>{
653
673
  let end = process.hrtime.bigint();
654
- console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
674
+ console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
655
675
  }).catch((err)=>{
656
- if (err.name === 'CssSyntaxError') {
676
+ if (err.name === "CssSyntaxError") {
657
677
  console.error(err.toString());
658
678
  } else {
659
679
  console.error(err);
@@ -662,18 +682,18 @@ async function build() {
662
682
  }
663
683
  let css2 = await (()=>{
664
684
  // Piping in data, let's drain the stdin
665
- if (input === '-') {
685
+ if (input === "-") {
666
686
  return drainStdin();
667
687
  }
668
688
  // Input file has been provided
669
689
  if (input) {
670
- return _fs.default.readFileSync(_path.default.resolve(input), 'utf8');
690
+ return _fs.default.readFileSync(_path.default.resolve(input), "utf8");
671
691
  }
672
692
  // No input file provided, fallback to default atrules
673
- return '@tailwind base; @tailwind components; @tailwind utilities';
693
+ return "@tailwind base; @tailwind components; @tailwind utilities";
674
694
  })();
675
695
  let result1 = await processCSS(css2);
676
- env.DEBUG && console.timeEnd('Finished in');
696
+ env.DEBUG && console.timeEnd("Finished in");
677
697
  return result1;
678
698
  }
679
699
  let config1 = refreshConfig(configPath);
@@ -684,24 +704,26 @@ async function build() {
684
704
  ...contextDependencies,
685
705
  ...extractFileGlobs(config1)
686
706
  ], {
707
+ usePolling: shouldPoll,
708
+ interval: shouldPoll ? pollInterval : undefined,
687
709
  ignoreInitial: true,
688
- awaitWriteFinish: process.platform === 'win32' ? {
710
+ awaitWriteFinish: shouldCoalesceWriteEvents ? {
689
711
  stabilityThreshold: 50,
690
- pollInterval: 10
712
+ pollInterval: pollInterval
691
713
  } : false
692
714
  });
693
715
  let chain = Promise.resolve();
694
- watcher.on('change', async (file)=>{
716
+ watcher.on("change", async (file)=>{
695
717
  if (contextDependencies.has(file)) {
696
- env.DEBUG && console.time('Resolve config');
718
+ env.DEBUG && console.time("Resolve config");
697
719
  context = null;
698
720
  config1 = refreshConfig(configPath);
699
- env.DEBUG && console.timeEnd('Resolve config');
700
- env.DEBUG && console.time('Watch new files');
721
+ env.DEBUG && console.timeEnd("Resolve config");
722
+ env.DEBUG && console.time("Watch new files");
701
723
  let globs = extractFileGlobs(config1);
702
724
  watcher.add(configDependencies);
703
725
  watcher.add(globs);
704
- env.DEBUG && console.timeEnd('Watch new files');
726
+ env.DEBUG && console.timeEnd("Watch new files");
705
727
  chain = chain.then(async ()=>{
706
728
  changedContent.push(...getChangedContent(config1));
707
729
  await rebuild(config1);
@@ -709,17 +731,17 @@ async function build() {
709
731
  } else {
710
732
  chain = chain.then(async ()=>{
711
733
  changedContent.push({
712
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
734
+ content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
713
735
  extension: _path.default.extname(file).slice(1)
714
736
  });
715
737
  await rebuild(config1);
716
738
  });
717
739
  }
718
740
  });
719
- watcher.on('add', async (file)=>{
741
+ watcher.on("add", async (file)=>{
720
742
  chain = chain.then(async ()=>{
721
743
  changedContent.push({
722
- content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
744
+ content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
723
745
  extension: _path.default.extname(file).slice(1)
724
746
  });
725
747
  await rebuild(config1);
@@ -731,7 +753,7 @@ async function build() {
731
753
  });
732
754
  }
733
755
  if (shouldWatch) {
734
- /* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.on('end', ()=>process.exit(0)
756
+ /* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.on("end", ()=>process.exit(0)
735
757
  );
736
758
  process.stdin.resume();
737
759
  startWatcher();