tailwindcss 0.0.0-insiders.aeaa2a3 → 0.0.0-insiders.aedfc6c
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 +327 -2
- 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 +253 -198
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +9 -1
- package/lib/corePlugins.js +1796 -1758
- package/lib/css/preflight.css +12 -5
- package/lib/featureFlags.js +13 -14
- 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 +372 -157
- package/lib/lib/expandTailwindAtRules.js +142 -123
- package/lib/lib/generateRules.js +345 -101
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +43 -35
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +83 -65
- package/lib/lib/setupContextUtils.js +259 -195
- package/lib/lib/setupTrackingContext.js +57 -56
- package/lib/lib/sharedState.js +38 -5
- 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 +19 -9
- package/lib/public/colors.js +241 -241
- 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 +40 -24
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +11 -15
- package/lib/util/dataTypes.js +111 -73
- 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 +11 -7
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +87 -44
- 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 +34 -165
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +75 -54
- 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 +38 -40
- package/peers/index.js +9074 -10316
- package/plugin.d.ts +6 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +52 -0
- package/src/cli.js +97 -27
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +492 -522
- package/src/css/preflight.css +12 -5
- package/src/featureFlags.js +3 -3
- 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 +75 -33
- package/src/lib/generateRules.js +337 -80
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/resolveDefaultsAtRules.js +35 -10
- package/src/lib/setupContextUtils.js +211 -110
- package/src/lib/setupTrackingContext.js +8 -7
- package/src/lib/sharedState.js +42 -4
- 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 +14 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -10
- package/src/util/dataTypes.js +55 -15
- 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 +10 -6
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +35 -2
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +119 -0
- package/src/util/pluginUtils.js +15 -138
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +41 -1
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +22 -7
- package/stubs/defaultConfig.stub.js +45 -16
- 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 -288
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -311
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"
|
|
161
|
+
},
|
|
162
|
+
"--watch": {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
description: "Watch for changes and rebuild as needed"
|
|
139
165
|
},
|
|
140
|
-
|
|
166
|
+
"--poll": {
|
|
141
167
|
type: Boolean,
|
|
142
|
-
description:
|
|
168
|
+
description: "Use polling instead of filesystem events when watching"
|
|
143
169
|
},
|
|
144
|
-
|
|
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,35 +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[
|
|
426
|
+
if (!args["--content"]) {
|
|
427
|
+
args["--content"] = args["--purge"];
|
|
396
428
|
}
|
|
397
429
|
}
|
|
398
|
-
if (args[
|
|
399
|
-
|
|
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;
|
|
400
439
|
}
|
|
401
|
-
return
|
|
440
|
+
return (0, _resolveConfig).default(config);
|
|
402
441
|
}
|
|
403
442
|
function extractFileGlobs(config) {
|
|
404
443
|
return config.content.files.filter((file)=>{
|
|
405
444
|
// Strings in this case are files / globs. If it is something else,
|
|
406
445
|
// like an object it's probably a raw content object. But this object
|
|
407
446
|
// is not watchable, so let's remove it.
|
|
408
|
-
return typeof file ===
|
|
447
|
+
return typeof file === "string";
|
|
409
448
|
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
410
449
|
);
|
|
411
450
|
}
|
|
412
451
|
function extractRawContent(config) {
|
|
413
452
|
return config.content.files.filter((file)=>{
|
|
414
|
-
return typeof file ===
|
|
453
|
+
return typeof file === "object" && file !== null;
|
|
415
454
|
});
|
|
416
455
|
}
|
|
417
456
|
function getChangedContent(config) {
|
|
@@ -421,12 +460,12 @@ async function build() {
|
|
|
421
460
|
let files = _fastGlob.default.sync(globs);
|
|
422
461
|
for (let file of files){
|
|
423
462
|
changedContent.push({
|
|
424
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
463
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
425
464
|
extension: _path.default.extname(file).slice(1)
|
|
426
465
|
});
|
|
427
466
|
}
|
|
428
467
|
// Resolve raw content in the tailwind config
|
|
429
|
-
for (let { raw: content , extension =
|
|
468
|
+
for (let { raw: content , extension ="html" } of extractRawContent(config)){
|
|
430
469
|
changedContent.push({
|
|
431
470
|
content,
|
|
432
471
|
extension
|
|
@@ -439,7 +478,7 @@ async function build() {
|
|
|
439
478
|
let changedContent = getChangedContent(config);
|
|
440
479
|
let tailwindPlugin = ()=>{
|
|
441
480
|
return {
|
|
442
|
-
postcssPlugin:
|
|
481
|
+
postcssPlugin: "tailwindcss",
|
|
443
482
|
Once (root, { result }) {
|
|
444
483
|
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
445
484
|
return ()=>{
|
|
@@ -457,20 +496,19 @@ async function build() {
|
|
|
457
496
|
let plugins = [
|
|
458
497
|
...beforePlugins,
|
|
459
498
|
tailwindPlugin,
|
|
460
|
-
!args[
|
|
499
|
+
!args["--minify"] && formatNodes,
|
|
461
500
|
...afterPlugins,
|
|
462
|
-
!args[
|
|
501
|
+
!args["--no-autoprefixer"] && (()=>{
|
|
463
502
|
// Try to load a local `autoprefixer` version first
|
|
464
503
|
try {
|
|
465
|
-
return require(
|
|
466
|
-
} catch {
|
|
467
|
-
}
|
|
504
|
+
return require("autoprefixer");
|
|
505
|
+
} catch {}
|
|
468
506
|
return (0, _indexJs).lazyAutoprefixer();
|
|
469
507
|
})(),
|
|
470
|
-
args[
|
|
508
|
+
args["--minify"] && (()=>{
|
|
471
509
|
let options = {
|
|
472
510
|
preset: [
|
|
473
|
-
|
|
511
|
+
"default",
|
|
474
512
|
{
|
|
475
513
|
cssDeclarationSorter: false
|
|
476
514
|
}
|
|
@@ -478,9 +516,8 @@ async function build() {
|
|
|
478
516
|
};
|
|
479
517
|
// Try to load a local `cssnano` version first
|
|
480
518
|
try {
|
|
481
|
-
return require(
|
|
482
|
-
} catch {
|
|
483
|
-
}
|
|
519
|
+
return require("cssnano");
|
|
520
|
+
} catch {}
|
|
484
521
|
return (0, _indexJs).lazyCssnano()(options);
|
|
485
522
|
})(),
|
|
486
523
|
].filter(Boolean);
|
|
@@ -499,19 +536,28 @@ async function build() {
|
|
|
499
536
|
return process.stdout.write(result.css);
|
|
500
537
|
}
|
|
501
538
|
return Promise.all([
|
|
502
|
-
|
|
503
|
-
),
|
|
504
|
-
result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
|
|
505
|
-
),
|
|
539
|
+
outputFile(output, result.css),
|
|
540
|
+
result.map && outputFile(output + ".map", result.map.toString()),
|
|
506
541
|
].filter(Boolean));
|
|
507
542
|
}).then(()=>{
|
|
508
543
|
let end = process.hrtime.bigint();
|
|
509
544
|
console.error();
|
|
510
|
-
console.error(
|
|
545
|
+
console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
|
|
511
546
|
});
|
|
512
547
|
}
|
|
513
|
-
let
|
|
514
|
-
|
|
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);
|
|
515
561
|
}
|
|
516
562
|
let context = null;
|
|
517
563
|
async function startWatcher() {
|
|
@@ -520,9 +566,9 @@ async function build() {
|
|
|
520
566
|
let contextDependencies = new Set();
|
|
521
567
|
let watcher = null;
|
|
522
568
|
function refreshConfig() {
|
|
523
|
-
env.DEBUG && console.time(
|
|
524
|
-
for (let
|
|
525
|
-
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)];
|
|
526
572
|
}
|
|
527
573
|
if (configPath) {
|
|
528
574
|
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
@@ -531,7 +577,7 @@ async function build() {
|
|
|
531
577
|
contextDependencies.add(dependency);
|
|
532
578
|
}
|
|
533
579
|
}
|
|
534
|
-
env.DEBUG && console.timeEnd(
|
|
580
|
+
env.DEBUG && console.timeEnd("Module dependencies");
|
|
535
581
|
return resolveConfig();
|
|
536
582
|
}
|
|
537
583
|
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
|
|
@@ -540,21 +586,20 @@ async function build() {
|
|
|
540
586
|
];
|
|
541
587
|
let plugins = [
|
|
542
588
|
...beforePlugins,
|
|
543
|
-
|
|
544
|
-
!args[
|
|
589
|
+
"__TAILWIND_PLUGIN_POSITION__",
|
|
590
|
+
!args["--minify"] && formatNodes,
|
|
545
591
|
...afterPlugins,
|
|
546
|
-
!args[
|
|
592
|
+
!args["--no-autoprefixer"] && (()=>{
|
|
547
593
|
// Try to load a local `autoprefixer` version first
|
|
548
594
|
try {
|
|
549
|
-
return require(
|
|
550
|
-
} catch {
|
|
551
|
-
}
|
|
595
|
+
return require("autoprefixer");
|
|
596
|
+
} catch {}
|
|
552
597
|
return (0, _indexJs).lazyAutoprefixer();
|
|
553
598
|
})(),
|
|
554
|
-
args[
|
|
599
|
+
args["--minify"] && (()=>{
|
|
555
600
|
let options = {
|
|
556
601
|
preset: [
|
|
557
|
-
|
|
602
|
+
"default",
|
|
558
603
|
{
|
|
559
604
|
cssDeclarationSorter: false
|
|
560
605
|
}
|
|
@@ -562,39 +607,38 @@ async function build() {
|
|
|
562
607
|
};
|
|
563
608
|
// Try to load a local `cssnano` version first
|
|
564
609
|
try {
|
|
565
|
-
return require(
|
|
566
|
-
} catch {
|
|
567
|
-
}
|
|
610
|
+
return require("cssnano");
|
|
611
|
+
} catch {}
|
|
568
612
|
return (0, _indexJs).lazyCssnano()(options);
|
|
569
613
|
})(),
|
|
570
614
|
].filter(Boolean);
|
|
571
615
|
async function rebuild(config) {
|
|
572
|
-
env.DEBUG && console.time(
|
|
616
|
+
env.DEBUG && console.time("Finished in");
|
|
573
617
|
let tailwindPlugin = ()=>{
|
|
574
618
|
return {
|
|
575
|
-
postcssPlugin:
|
|
619
|
+
postcssPlugin: "tailwindcss",
|
|
576
620
|
Once (root, { result }) {
|
|
577
|
-
env.DEBUG && console.time(
|
|
621
|
+
env.DEBUG && console.time("Compiling CSS");
|
|
578
622
|
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
579
623
|
console.error();
|
|
580
|
-
console.error(
|
|
624
|
+
console.error("Rebuilding...");
|
|
581
625
|
return ()=>{
|
|
582
626
|
if (context !== null) {
|
|
583
627
|
context.changedContent = changedContent.splice(0);
|
|
584
628
|
return context;
|
|
585
629
|
}
|
|
586
|
-
env.DEBUG && console.time(
|
|
630
|
+
env.DEBUG && console.time("Creating context");
|
|
587
631
|
context = createContext(config, changedContent.splice(0));
|
|
588
|
-
env.DEBUG && console.timeEnd(
|
|
632
|
+
env.DEBUG && console.timeEnd("Creating context");
|
|
589
633
|
return context;
|
|
590
634
|
};
|
|
591
635
|
})(root, result);
|
|
592
|
-
env.DEBUG && console.timeEnd(
|
|
636
|
+
env.DEBUG && console.timeEnd("Compiling CSS");
|
|
593
637
|
}
|
|
594
638
|
};
|
|
595
639
|
};
|
|
596
640
|
tailwindPlugin.postcss = true;
|
|
597
|
-
let tailwindPluginIdx = plugins.indexOf(
|
|
641
|
+
let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
|
|
598
642
|
let copy = plugins.slice();
|
|
599
643
|
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
600
644
|
let processor = (0, _indexJs).postcss(copy);
|
|
@@ -609,7 +653,7 @@ async function build() {
|
|
|
609
653
|
})
|
|
610
654
|
).then(async (result)=>{
|
|
611
655
|
for (let message of result.messages){
|
|
612
|
-
if (message.type ===
|
|
656
|
+
if (message.type === "dependency") {
|
|
613
657
|
contextDependencies.add(message.file);
|
|
614
658
|
}
|
|
615
659
|
}
|
|
@@ -619,84 +663,95 @@ async function build() {
|
|
|
619
663
|
if (!output) {
|
|
620
664
|
return process.stdout.write(result.css);
|
|
621
665
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
),
|
|
625
|
-
result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
|
|
626
|
-
),
|
|
666
|
+
return Promise.all([
|
|
667
|
+
outputFile(output, result.css),
|
|
668
|
+
result.map && outputFile(output + ".map", result.map.toString()),
|
|
627
669
|
].filter(Boolean));
|
|
628
670
|
}).then(()=>{
|
|
629
671
|
let end = process.hrtime.bigint();
|
|
630
|
-
console.error(
|
|
672
|
+
console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
|
|
631
673
|
}).catch((err)=>{
|
|
632
|
-
if (err.name ===
|
|
674
|
+
if (err.name === "CssSyntaxError") {
|
|
633
675
|
console.error(err.toString());
|
|
634
676
|
} else {
|
|
635
677
|
console.error(err);
|
|
636
678
|
}
|
|
637
679
|
});
|
|
638
680
|
}
|
|
639
|
-
let
|
|
640
|
-
|
|
641
|
-
|
|
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");
|
|
642
695
|
return result1;
|
|
643
696
|
}
|
|
644
|
-
let
|
|
697
|
+
let config1 = refreshConfig(configPath);
|
|
645
698
|
if (input) {
|
|
646
699
|
contextDependencies.add(_path.default.resolve(input));
|
|
647
700
|
}
|
|
648
701
|
watcher = _chokidar.default.watch([
|
|
649
702
|
...contextDependencies,
|
|
650
|
-
...extractFileGlobs(
|
|
703
|
+
...extractFileGlobs(config1)
|
|
651
704
|
], {
|
|
705
|
+
usePolling: shouldPoll,
|
|
706
|
+
interval: shouldPoll ? pollInterval : undefined,
|
|
652
707
|
ignoreInitial: true,
|
|
653
|
-
awaitWriteFinish:
|
|
708
|
+
awaitWriteFinish: shouldCoalesceWriteEvents ? {
|
|
654
709
|
stabilityThreshold: 50,
|
|
655
|
-
pollInterval:
|
|
710
|
+
pollInterval: pollInterval
|
|
656
711
|
} : false
|
|
657
712
|
});
|
|
658
713
|
let chain = Promise.resolve();
|
|
659
|
-
watcher.on(
|
|
714
|
+
watcher.on("change", async (file)=>{
|
|
660
715
|
if (contextDependencies.has(file)) {
|
|
661
|
-
env.DEBUG && console.time(
|
|
716
|
+
env.DEBUG && console.time("Resolve config");
|
|
662
717
|
context = null;
|
|
663
|
-
|
|
664
|
-
env.DEBUG && console.timeEnd(
|
|
665
|
-
env.DEBUG && console.time(
|
|
666
|
-
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);
|
|
667
722
|
watcher.add(configDependencies);
|
|
668
723
|
watcher.add(globs);
|
|
669
|
-
env.DEBUG && console.timeEnd(
|
|
724
|
+
env.DEBUG && console.timeEnd("Watch new files");
|
|
670
725
|
chain = chain.then(async ()=>{
|
|
671
|
-
changedContent.push(...getChangedContent(
|
|
672
|
-
await rebuild(
|
|
726
|
+
changedContent.push(...getChangedContent(config1));
|
|
727
|
+
await rebuild(config1);
|
|
673
728
|
});
|
|
674
729
|
} else {
|
|
675
730
|
chain = chain.then(async ()=>{
|
|
676
731
|
changedContent.push({
|
|
677
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
732
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
678
733
|
extension: _path.default.extname(file).slice(1)
|
|
679
734
|
});
|
|
680
|
-
await rebuild(
|
|
735
|
+
await rebuild(config1);
|
|
681
736
|
});
|
|
682
737
|
}
|
|
683
738
|
});
|
|
684
|
-
watcher.on(
|
|
739
|
+
watcher.on("add", async (file)=>{
|
|
685
740
|
chain = chain.then(async ()=>{
|
|
686
741
|
changedContent.push({
|
|
687
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
742
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
688
743
|
extension: _path.default.extname(file).slice(1)
|
|
689
744
|
});
|
|
690
|
-
await rebuild(
|
|
745
|
+
await rebuild(config1);
|
|
691
746
|
});
|
|
692
747
|
});
|
|
693
748
|
chain = chain.then(()=>{
|
|
694
|
-
changedContent.push(...getChangedContent(
|
|
695
|
-
return rebuild(
|
|
749
|
+
changedContent.push(...getChangedContent(config1));
|
|
750
|
+
return rebuild(config1);
|
|
696
751
|
});
|
|
697
752
|
}
|
|
698
753
|
if (shouldWatch) {
|
|
699
|
-
/* 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)
|
|
700
755
|
);
|
|
701
756
|
process.stdin.resume();
|
|
702
757
|
startWatcher();
|