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