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