tailwindcss 0.0.0-insiders.de1bdb4 → 0.0.0-insiders.deefbf5

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