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