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