tailwindcss 0.0.0-insiders.d2b53cd → 0.0.0-insiders.d2fdf9e
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 +364 -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 +10 -5
- package/lib/cli.js +306 -203
- package/lib/constants.js +9 -9
- package/lib/corePluginList.js +10 -1
- package/lib/corePlugins.js +1835 -1760
- package/lib/css/preflight.css +19 -13
- package/lib/featureFlags.js +18 -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 +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 +145 -126
- package/lib/lib/generateRules.js +403 -103
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +43 -35
- package/lib/lib/partitionApplyAtRules.js +53 -0
- package/lib/lib/regex.js +53 -0
- package/lib/lib/resolveDefaultsAtRules.js +83 -65
- package/lib/lib/setupContextUtils.js +315 -204
- package/lib/lib/setupTrackingContext.js +60 -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 +43 -32
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +11 -15
- 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 +11 -7
- package/lib/util/nameClass.js +7 -6
- package/lib/util/negateValue.js +4 -4
- package/lib/util/normalizeConfig.js +84 -45
- 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 +34 -165
- package/lib/util/prefixSelector.js +4 -7
- package/lib/util/resolveConfig.js +115 -66
- 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 +39 -40
- package/peers/index.js +11511 -10819
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +164 -30
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +540 -535
- package/src/css/preflight.css +19 -13
- package/src/featureFlags.js +5 -5
- 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 +79 -37
- package/src/lib/generateRules.js +400 -83
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +35 -10
- package/src/lib/setupContextUtils.js +273 -112
- package/src/lib/setupTrackingContext.js +12 -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 +31 -14
- 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 +10 -6
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeConfig.js +32 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/pluginUtils.js +15 -138
- package/src/util/prefixSelector.js +7 -8
- package/src/util/resolveConfig.js +97 -15
- 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 +47 -17
- 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 -304
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": {
|
|
162
|
+
type: Boolean,
|
|
163
|
+
description: `Initialize a full \`${configs.tailwind}\` file`
|
|
164
|
+
},
|
|
165
|
+
"--postcss": {
|
|
118
166
|
type: Boolean,
|
|
119
|
-
description:
|
|
167
|
+
description: `Initialize a \`${configs.postcss}\` file`
|
|
120
168
|
},
|
|
121
|
-
|
|
169
|
+
"--types": {
|
|
122
170
|
type: Boolean,
|
|
123
|
-
description:
|
|
171
|
+
description: `Add TypeScript types for the \`${configs.tailwind}\` file`
|
|
124
172
|
},
|
|
125
|
-
|
|
126
|
-
|
|
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,25 +442,34 @@ 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[
|
|
456
|
+
if (!args["--content"]) {
|
|
457
|
+
args["--content"] = args["--purge"];
|
|
396
458
|
}
|
|
397
459
|
}
|
|
398
|
-
if (args[
|
|
399
|
-
|
|
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;
|
|
400
470
|
}
|
|
471
|
+
let resolvedConfig = (0, _resolveConfig).default(config);
|
|
472
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
401
473
|
return resolvedConfig;
|
|
402
474
|
}
|
|
403
475
|
function extractFileGlobs(config) {
|
|
@@ -405,13 +477,13 @@ async function build() {
|
|
|
405
477
|
// Strings in this case are files / globs. If it is something else,
|
|
406
478
|
// like an object it's probably a raw content object. But this object
|
|
407
479
|
// is not watchable, so let's remove it.
|
|
408
|
-
return typeof file ===
|
|
480
|
+
return typeof file === "string";
|
|
409
481
|
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
410
482
|
);
|
|
411
483
|
}
|
|
412
484
|
function extractRawContent(config) {
|
|
413
485
|
return config.content.files.filter((file)=>{
|
|
414
|
-
return typeof file ===
|
|
486
|
+
return typeof file === "object" && file !== null;
|
|
415
487
|
});
|
|
416
488
|
}
|
|
417
489
|
function getChangedContent(config) {
|
|
@@ -421,12 +493,12 @@ async function build() {
|
|
|
421
493
|
let files = _fastGlob.default.sync(globs);
|
|
422
494
|
for (let file of files){
|
|
423
495
|
changedContent.push({
|
|
424
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
496
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
425
497
|
extension: _path.default.extname(file).slice(1)
|
|
426
498
|
});
|
|
427
499
|
}
|
|
428
500
|
// Resolve raw content in the tailwind config
|
|
429
|
-
for (let { raw: content , extension =
|
|
501
|
+
for (let { raw: content , extension ="html" } of extractRawContent(config)){
|
|
430
502
|
changedContent.push({
|
|
431
503
|
content,
|
|
432
504
|
extension
|
|
@@ -439,7 +511,7 @@ async function build() {
|
|
|
439
511
|
let changedContent = getChangedContent(config);
|
|
440
512
|
let tailwindPlugin = ()=>{
|
|
441
513
|
return {
|
|
442
|
-
postcssPlugin:
|
|
514
|
+
postcssPlugin: "tailwindcss",
|
|
443
515
|
Once (root, { result }) {
|
|
444
516
|
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
445
517
|
return ()=>{
|
|
@@ -450,27 +522,34 @@ async function build() {
|
|
|
450
522
|
};
|
|
451
523
|
};
|
|
452
524
|
tailwindPlugin.postcss = true;
|
|
453
|
-
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
|
+
],
|
|
454
534
|
[],
|
|
455
|
-
|
|
535
|
+
{},
|
|
456
536
|
];
|
|
457
537
|
let plugins = [
|
|
458
538
|
...beforePlugins,
|
|
459
539
|
tailwindPlugin,
|
|
460
|
-
!args[
|
|
540
|
+
!args["--minify"] && formatNodes,
|
|
461
541
|
...afterPlugins,
|
|
462
|
-
!args[
|
|
542
|
+
!args["--no-autoprefixer"] && (()=>{
|
|
463
543
|
// Try to load a local `autoprefixer` version first
|
|
464
544
|
try {
|
|
465
|
-
return require(
|
|
466
|
-
} catch {
|
|
467
|
-
}
|
|
545
|
+
return require("autoprefixer");
|
|
546
|
+
} catch {}
|
|
468
547
|
return (0, _indexJs).lazyAutoprefixer();
|
|
469
548
|
})(),
|
|
470
|
-
args[
|
|
549
|
+
args["--minify"] && (()=>{
|
|
471
550
|
let options = {
|
|
472
551
|
preset: [
|
|
473
|
-
|
|
552
|
+
"default",
|
|
474
553
|
{
|
|
475
554
|
cssDeclarationSorter: false
|
|
476
555
|
}
|
|
@@ -478,19 +557,20 @@ async function build() {
|
|
|
478
557
|
};
|
|
479
558
|
// Try to load a local `cssnano` version first
|
|
480
559
|
try {
|
|
481
|
-
return require(
|
|
482
|
-
} catch {
|
|
483
|
-
}
|
|
560
|
+
return require("cssnano");
|
|
561
|
+
} catch {}
|
|
484
562
|
return (0, _indexJs).lazyCssnano()(options);
|
|
485
563
|
})(),
|
|
486
564
|
].filter(Boolean);
|
|
487
|
-
let
|
|
565
|
+
let postcss = loadPostcss();
|
|
566
|
+
let processor = postcss(plugins);
|
|
488
567
|
function processCSS(css) {
|
|
489
568
|
let start = process.hrtime.bigint();
|
|
490
569
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
491
570
|
recursive: true
|
|
492
571
|
}) : null
|
|
493
572
|
).then(()=>processor.process(css, {
|
|
573
|
+
...postcssOptions,
|
|
494
574
|
from: input,
|
|
495
575
|
to: output
|
|
496
576
|
})
|
|
@@ -499,19 +579,28 @@ async function build() {
|
|
|
499
579
|
return process.stdout.write(result.css);
|
|
500
580
|
}
|
|
501
581
|
return Promise.all([
|
|
502
|
-
|
|
503
|
-
),
|
|
504
|
-
result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
|
|
505
|
-
),
|
|
582
|
+
outputFile(output, result.css),
|
|
583
|
+
result.map && outputFile(output + ".map", result.map.toString()),
|
|
506
584
|
].filter(Boolean));
|
|
507
585
|
}).then(()=>{
|
|
508
586
|
let end = process.hrtime.bigint();
|
|
509
587
|
console.error();
|
|
510
|
-
console.error(
|
|
588
|
+
console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
|
|
511
589
|
});
|
|
512
590
|
}
|
|
513
|
-
let
|
|
514
|
-
|
|
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);
|
|
515
604
|
}
|
|
516
605
|
let context = null;
|
|
517
606
|
async function startWatcher() {
|
|
@@ -520,9 +609,9 @@ async function build() {
|
|
|
520
609
|
let contextDependencies = new Set();
|
|
521
610
|
let watcher = null;
|
|
522
611
|
function refreshConfig() {
|
|
523
|
-
env.DEBUG && console.time(
|
|
524
|
-
for (let
|
|
525
|
-
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)];
|
|
526
615
|
}
|
|
527
616
|
if (configPath) {
|
|
528
617
|
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
@@ -531,7 +620,7 @@ async function build() {
|
|
|
531
620
|
contextDependencies.add(dependency);
|
|
532
621
|
}
|
|
533
622
|
}
|
|
534
|
-
env.DEBUG && console.timeEnd(
|
|
623
|
+
env.DEBUG && console.timeEnd("Module dependencies");
|
|
535
624
|
return resolveConfig();
|
|
536
625
|
}
|
|
537
626
|
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
|
|
@@ -540,21 +629,20 @@ async function build() {
|
|
|
540
629
|
];
|
|
541
630
|
let plugins = [
|
|
542
631
|
...beforePlugins,
|
|
543
|
-
|
|
544
|
-
!args[
|
|
632
|
+
"__TAILWIND_PLUGIN_POSITION__",
|
|
633
|
+
!args["--minify"] && formatNodes,
|
|
545
634
|
...afterPlugins,
|
|
546
|
-
!args[
|
|
635
|
+
!args["--no-autoprefixer"] && (()=>{
|
|
547
636
|
// Try to load a local `autoprefixer` version first
|
|
548
637
|
try {
|
|
549
|
-
return require(
|
|
550
|
-
} catch {
|
|
551
|
-
}
|
|
638
|
+
return require("autoprefixer");
|
|
639
|
+
} catch {}
|
|
552
640
|
return (0, _indexJs).lazyAutoprefixer();
|
|
553
641
|
})(),
|
|
554
|
-
args[
|
|
642
|
+
args["--minify"] && (()=>{
|
|
555
643
|
let options = {
|
|
556
644
|
preset: [
|
|
557
|
-
|
|
645
|
+
"default",
|
|
558
646
|
{
|
|
559
647
|
cssDeclarationSorter: false
|
|
560
648
|
}
|
|
@@ -562,42 +650,42 @@ async function build() {
|
|
|
562
650
|
};
|
|
563
651
|
// Try to load a local `cssnano` version first
|
|
564
652
|
try {
|
|
565
|
-
return require(
|
|
566
|
-
} catch {
|
|
567
|
-
}
|
|
653
|
+
return require("cssnano");
|
|
654
|
+
} catch {}
|
|
568
655
|
return (0, _indexJs).lazyCssnano()(options);
|
|
569
656
|
})(),
|
|
570
657
|
].filter(Boolean);
|
|
571
658
|
async function rebuild(config) {
|
|
572
|
-
env.DEBUG && console.time(
|
|
659
|
+
env.DEBUG && console.time("Finished in");
|
|
573
660
|
let tailwindPlugin = ()=>{
|
|
574
661
|
return {
|
|
575
|
-
postcssPlugin:
|
|
662
|
+
postcssPlugin: "tailwindcss",
|
|
576
663
|
Once (root, { result }) {
|
|
577
|
-
env.DEBUG && console.time(
|
|
664
|
+
env.DEBUG && console.time("Compiling CSS");
|
|
578
665
|
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
579
666
|
console.error();
|
|
580
|
-
console.error(
|
|
667
|
+
console.error("Rebuilding...");
|
|
581
668
|
return ()=>{
|
|
582
669
|
if (context !== null) {
|
|
583
670
|
context.changedContent = changedContent.splice(0);
|
|
584
671
|
return context;
|
|
585
672
|
}
|
|
586
|
-
env.DEBUG && console.time(
|
|
673
|
+
env.DEBUG && console.time("Creating context");
|
|
587
674
|
context = createContext(config, changedContent.splice(0));
|
|
588
|
-
env.DEBUG && console.timeEnd(
|
|
675
|
+
env.DEBUG && console.timeEnd("Creating context");
|
|
589
676
|
return context;
|
|
590
677
|
};
|
|
591
678
|
})(root, result);
|
|
592
|
-
env.DEBUG && console.timeEnd(
|
|
679
|
+
env.DEBUG && console.timeEnd("Compiling CSS");
|
|
593
680
|
}
|
|
594
681
|
};
|
|
595
682
|
};
|
|
596
683
|
tailwindPlugin.postcss = true;
|
|
597
|
-
let tailwindPluginIdx = plugins.indexOf(
|
|
684
|
+
let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
|
|
598
685
|
let copy = plugins.slice();
|
|
599
686
|
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
600
|
-
let
|
|
687
|
+
let postcss = loadPostcss();
|
|
688
|
+
let processor = postcss(copy);
|
|
601
689
|
function processCSS(css) {
|
|
602
690
|
let start = process.hrtime.bigint();
|
|
603
691
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
@@ -609,7 +697,7 @@ async function build() {
|
|
|
609
697
|
})
|
|
610
698
|
).then(async (result)=>{
|
|
611
699
|
for (let message of result.messages){
|
|
612
|
-
if (message.type ===
|
|
700
|
+
if (message.type === "dependency") {
|
|
613
701
|
contextDependencies.add(message.file);
|
|
614
702
|
}
|
|
615
703
|
}
|
|
@@ -619,80 +707,95 @@ async function build() {
|
|
|
619
707
|
if (!output) {
|
|
620
708
|
return process.stdout.write(result.css);
|
|
621
709
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
),
|
|
625
|
-
result.map && _fs.default.writeFile(output + '.map', result.map.toString(), ()=>true
|
|
626
|
-
),
|
|
710
|
+
return Promise.all([
|
|
711
|
+
outputFile(output, result.css),
|
|
712
|
+
result.map && outputFile(output + ".map", result.map.toString()),
|
|
627
713
|
].filter(Boolean));
|
|
628
714
|
}).then(()=>{
|
|
629
715
|
let end = process.hrtime.bigint();
|
|
630
|
-
console.error(
|
|
716
|
+
console.error("Done in", (end - start) / BigInt(1000000) + "ms.");
|
|
631
717
|
}).catch((err)=>{
|
|
632
|
-
if (err.name ===
|
|
718
|
+
if (err.name === "CssSyntaxError") {
|
|
633
719
|
console.error(err.toString());
|
|
634
720
|
} else {
|
|
635
721
|
console.error(err);
|
|
636
722
|
}
|
|
637
723
|
});
|
|
638
724
|
}
|
|
639
|
-
let
|
|
640
|
-
|
|
641
|
-
|
|
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");
|
|
642
739
|
return result1;
|
|
643
740
|
}
|
|
644
|
-
let
|
|
741
|
+
let config2 = refreshConfig(configPath);
|
|
645
742
|
if (input) {
|
|
646
743
|
contextDependencies.add(_path.default.resolve(input));
|
|
647
744
|
}
|
|
648
745
|
watcher = _chokidar.default.watch([
|
|
649
746
|
...contextDependencies,
|
|
650
|
-
...extractFileGlobs(
|
|
747
|
+
...extractFileGlobs(config2)
|
|
651
748
|
], {
|
|
652
|
-
|
|
749
|
+
usePolling: shouldPoll,
|
|
750
|
+
interval: shouldPoll ? pollInterval : undefined,
|
|
751
|
+
ignoreInitial: true,
|
|
752
|
+
awaitWriteFinish: shouldCoalesceWriteEvents ? {
|
|
753
|
+
stabilityThreshold: 50,
|
|
754
|
+
pollInterval: pollInterval
|
|
755
|
+
} : false
|
|
653
756
|
});
|
|
654
757
|
let chain = Promise.resolve();
|
|
655
|
-
watcher.on(
|
|
758
|
+
watcher.on("change", async (file)=>{
|
|
656
759
|
if (contextDependencies.has(file)) {
|
|
657
|
-
env.DEBUG && console.time(
|
|
760
|
+
env.DEBUG && console.time("Resolve config");
|
|
658
761
|
context = null;
|
|
659
|
-
|
|
660
|
-
env.DEBUG && console.timeEnd(
|
|
661
|
-
env.DEBUG && console.time(
|
|
662
|
-
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);
|
|
663
766
|
watcher.add(configDependencies);
|
|
664
767
|
watcher.add(globs);
|
|
665
|
-
env.DEBUG && console.timeEnd(
|
|
768
|
+
env.DEBUG && console.timeEnd("Watch new files");
|
|
666
769
|
chain = chain.then(async ()=>{
|
|
667
|
-
changedContent.push(...getChangedContent(
|
|
668
|
-
await rebuild(
|
|
770
|
+
changedContent.push(...getChangedContent(config2));
|
|
771
|
+
await rebuild(config2);
|
|
669
772
|
});
|
|
670
773
|
} else {
|
|
671
774
|
chain = chain.then(async ()=>{
|
|
672
775
|
changedContent.push({
|
|
673
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
776
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
674
777
|
extension: _path.default.extname(file).slice(1)
|
|
675
778
|
});
|
|
676
|
-
await rebuild(
|
|
779
|
+
await rebuild(config2);
|
|
677
780
|
});
|
|
678
781
|
}
|
|
679
782
|
});
|
|
680
|
-
watcher.on(
|
|
783
|
+
watcher.on("add", async (file)=>{
|
|
681
784
|
chain = chain.then(async ()=>{
|
|
682
785
|
changedContent.push({
|
|
683
|
-
content: _fs.default.readFileSync(_path.default.resolve(file),
|
|
786
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
684
787
|
extension: _path.default.extname(file).slice(1)
|
|
685
788
|
});
|
|
686
|
-
await rebuild(
|
|
789
|
+
await rebuild(config2);
|
|
687
790
|
});
|
|
688
791
|
});
|
|
689
792
|
chain = chain.then(()=>{
|
|
690
|
-
changedContent.push(...getChangedContent(
|
|
691
|
-
return rebuild(
|
|
793
|
+
changedContent.push(...getChangedContent(config2));
|
|
794
|
+
return rebuild(config2);
|
|
692
795
|
});
|
|
693
796
|
}
|
|
694
797
|
if (shouldWatch) {
|
|
695
|
-
/* 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)
|
|
696
799
|
);
|
|
697
800
|
process.stdin.resume();
|
|
698
801
|
startWatcher();
|