tailwindcss 0.0.0-insiders.cea3ccf → 0.0.0-insiders.cef02e2
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 +125 -6
- package/README.md +6 -3
- package/defaultTheme.d.ts +2 -1
- package/lib/cli-peer-dependencies.js +15 -3
- package/lib/cli.js +153 -123
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +304 -262
- package/lib/featureFlags.js +23 -13
- package/lib/index.js +10 -8
- package/lib/lib/cacheInvalidation.js +42 -21
- package/lib/lib/collapseAdjacentRules.js +15 -13
- package/lib/lib/collapseDuplicateDeclarations.js +11 -8
- package/lib/lib/defaultExtractor.js +146 -70
- package/lib/lib/detectNesting.js +4 -1
- package/lib/lib/evaluateTailwindFunctions.js +88 -41
- package/lib/lib/expandApplyAtRules.js +120 -83
- package/lib/lib/expandTailwindAtRules.js +156 -139
- package/lib/lib/generateRules.js +178 -95
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +10 -7
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +16 -9
- package/lib/lib/resolveDefaultsAtRules.js +97 -79
- package/lib/lib/setupContextUtils.js +226 -155
- package/lib/lib/setupTrackingContext.js +87 -80
- package/lib/lib/sharedState.js +16 -10
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +8 -6
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +6 -4
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +6 -4
- package/lib/util/cloneDeep.js +6 -5
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +16 -13
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +14 -12
- package/lib/util/dataTypes.js +35 -34
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +12 -9
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +7 -8
- package/lib/util/formatVariantSelector.js +33 -28
- package/lib/util/getAllConfigs.js +32 -13
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/isValidArbitraryValue.js +33 -25
- package/lib/util/log.js +14 -8
- package/lib/util/nameClass.js +16 -8
- package/lib/util/negateValue.js +5 -3
- package/lib/util/normalizeConfig.js +51 -38
- package/lib/util/normalizeScreens.js +18 -4
- package/lib/util/parseAnimationValue.js +43 -41
- package/lib/util/parseBoxShadowValue.js +12 -45
- package/lib/util/parseDependency.js +35 -32
- package/lib/util/parseObjectStyles.js +14 -11
- package/lib/util/pluginUtils.js +38 -22
- package/lib/util/prefixSelector.js +6 -3
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +101 -97
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +93 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +14 -9
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +32 -24
- package/package.json +20 -18
- package/peers/index.js +6436 -2873
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +3 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +4 -0
- package/src/cli.js +80 -23
- package/src/corePlugins.js +98 -46
- package/src/featureFlags.js +6 -2
- package/src/lib/defaultExtractor.js +92 -52
- package/src/lib/evaluateTailwindFunctions.js +56 -6
- package/src/lib/expandApplyAtRules.js +92 -19
- package/src/lib/expandTailwindAtRules.js +1 -1
- package/src/lib/generateRules.js +89 -15
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +121 -41
- package/src/lib/setupTrackingContext.js +5 -1
- package/src/util/cloneNodes.js +5 -1
- package/src/util/dataTypes.js +3 -5
- package/src/util/formatVariantSelector.js +22 -14
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/log.js +1 -1
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/pluginUtils.js +13 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +66 -52
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +2 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +33 -29
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -1
- package/types.d.ts +0 -1
package/lib/cli.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
= _interopRequireDefault(require("postcss-load-config
|
|
12
|
-
|
|
13
|
-
= _interopRequireDefault(require("postcss-load-config/src/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const _indexJs = require("../peers/index.js");
|
|
7
|
+
const _chokidar = /*#__PURE__*/ _interopRequireDefault(require("chokidar"));
|
|
8
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
9
|
+
const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
|
|
10
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
11
|
+
const _postcssLoadConfig = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config"));
|
|
12
|
+
const _lilconfig = require("lilconfig");
|
|
13
|
+
const _plugins = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
|
|
14
|
+
));
|
|
15
|
+
const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
|
|
16
|
+
));
|
|
17
|
+
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("./processTailwindFeatures"));
|
|
18
|
+
const _resolveConfig = /*#__PURE__*/ _interopRequireDefault(require("../resolveConfig"));
|
|
19
|
+
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
20
|
+
const _getModuleDependencies = /*#__PURE__*/ _interopRequireDefault(require("./lib/getModuleDependencies"));
|
|
21
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
|
|
22
|
+
const _packageJson = /*#__PURE__*/ _interopRequireDefault(require("../package.json"));
|
|
23
|
+
const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
24
|
+
const _validateConfigJs = require("./util/validateConfig.js");
|
|
21
25
|
function _interopRequireDefault(obj) {
|
|
22
26
|
return obj && obj.__esModule ? obj : {
|
|
23
27
|
default: obj
|
|
@@ -26,6 +30,22 @@ function _interopRequireDefault(obj) {
|
|
|
26
30
|
let env = {
|
|
27
31
|
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== "0"
|
|
28
32
|
};
|
|
33
|
+
function isESM() {
|
|
34
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
35
|
+
try {
|
|
36
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
37
|
+
return pkg.type && pkg.type === "module";
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let configs = isESM() ? {
|
|
43
|
+
tailwind: "tailwind.config.cjs",
|
|
44
|
+
postcss: "postcss.config.cjs"
|
|
45
|
+
} : {
|
|
46
|
+
tailwind: "tailwind.config.js",
|
|
47
|
+
postcss: "postcss.config.js"
|
|
48
|
+
};
|
|
29
49
|
// ---
|
|
30
50
|
function indentRecursive(node, indent = 0) {
|
|
31
51
|
node.each && node.each((child, i)=>{
|
|
@@ -55,13 +75,11 @@ function drainStdin() {
|
|
|
55
75
|
process.stdin.on("data", (chunk)=>{
|
|
56
76
|
result += chunk;
|
|
57
77
|
});
|
|
58
|
-
process.stdin.on("end", ()=>resolve(result)
|
|
59
|
-
);
|
|
60
|
-
process.stdin.on("error", (err)=>reject(err)
|
|
61
|
-
);
|
|
78
|
+
process.stdin.on("end", ()=>resolve(result));
|
|
79
|
+
process.stdin.on("error", (err)=>reject(err));
|
|
62
80
|
});
|
|
63
81
|
}
|
|
64
|
-
function help({ message , usage , commands
|
|
82
|
+
function help({ message , usage , commands , options }) {
|
|
65
83
|
let indent = 2;
|
|
66
84
|
// Render header
|
|
67
85
|
console.log();
|
|
@@ -82,11 +100,11 @@ function help({ message , usage , commands: commands1 , options }) {
|
|
|
82
100
|
}
|
|
83
101
|
}
|
|
84
102
|
// Render commands
|
|
85
|
-
if (
|
|
103
|
+
if (commands && commands.length > 0) {
|
|
86
104
|
console.log();
|
|
87
105
|
console.log("Commands:");
|
|
88
|
-
for (let
|
|
89
|
-
console.log(" ".repeat(indent),
|
|
106
|
+
for (let command of commands){
|
|
107
|
+
console.log(" ".repeat(indent), command);
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
// Render options
|
|
@@ -106,12 +124,12 @@ function help({ message , usage , commands: commands1 , options }) {
|
|
|
106
124
|
}
|
|
107
125
|
console.log();
|
|
108
126
|
console.log("Options:");
|
|
109
|
-
for (let { flags
|
|
127
|
+
for (let { flags , description , deprecated } of Object.values(groupedOptions)){
|
|
110
128
|
if (deprecated) continue;
|
|
111
|
-
if (
|
|
112
|
-
console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ),
|
|
129
|
+
if (flags.length === 1) {
|
|
130
|
+
console.log(" ".repeat(indent + 4 /* 4 = "-i, ".length */ ), flags.slice().reverse().join(", ").padEnd(20, " "), description);
|
|
113
131
|
} else {
|
|
114
|
-
console.log(" ".repeat(indent),
|
|
132
|
+
console.log(" ".repeat(indent), flags.slice().reverse().join(", ").padEnd(24, " "), description);
|
|
115
133
|
}
|
|
116
134
|
}
|
|
117
135
|
}
|
|
@@ -135,7 +153,7 @@ function loadPostcss() {
|
|
|
135
153
|
try {
|
|
136
154
|
return require("postcss");
|
|
137
155
|
} catch {}
|
|
138
|
-
return (0, _indexJs
|
|
156
|
+
return (0, _indexJs.lazyPostcss)();
|
|
139
157
|
}
|
|
140
158
|
let commands = {
|
|
141
159
|
init: {
|
|
@@ -143,15 +161,11 @@ let commands = {
|
|
|
143
161
|
args: {
|
|
144
162
|
"--full": {
|
|
145
163
|
type: Boolean,
|
|
146
|
-
description:
|
|
164
|
+
description: `Initialize a full \`${configs.tailwind}\` file`
|
|
147
165
|
},
|
|
148
166
|
"--postcss": {
|
|
149
167
|
type: Boolean,
|
|
150
|
-
description:
|
|
151
|
-
},
|
|
152
|
-
"--types": {
|
|
153
|
-
type: Boolean,
|
|
154
|
-
description: "Add TypeScript types for the `tailwind.config.js` file"
|
|
168
|
+
description: `Initialize a \`${configs.postcss}\` file`
|
|
155
169
|
},
|
|
156
170
|
"-f": "--full",
|
|
157
171
|
"-p": "--postcss"
|
|
@@ -216,16 +230,13 @@ let sharedFlags = {
|
|
|
216
230
|
},
|
|
217
231
|
"-h": "--help"
|
|
218
232
|
};
|
|
219
|
-
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined
|
|
220
|
-
))) {
|
|
233
|
+
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
221
234
|
help({
|
|
222
235
|
usage: [
|
|
223
236
|
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
|
224
|
-
"tailwindcss init [--full] [--postcss] [
|
|
237
|
+
"tailwindcss init [--full] [--postcss] [options...]",
|
|
225
238
|
],
|
|
226
|
-
commands: Object.keys(commands).filter((
|
|
227
|
-
).map((command3)=>`${command3} [options]`
|
|
228
|
-
),
|
|
239
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
229
240
|
options: {
|
|
230
241
|
...commands.build.args,
|
|
231
242
|
...sharedFlags
|
|
@@ -233,8 +244,7 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
233
244
|
});
|
|
234
245
|
process.exit(0);
|
|
235
246
|
}
|
|
236
|
-
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg
|
|
237
|
-
)(process.argv[2]) || "build";
|
|
247
|
+
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
|
|
238
248
|
if (commands[command] === undefined) {
|
|
239
249
|
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
240
250
|
// TODO: Deprecate this in future versions
|
|
@@ -246,9 +256,7 @@ if (commands[command] === undefined) {
|
|
|
246
256
|
usage: [
|
|
247
257
|
"tailwindcss <command> [options]"
|
|
248
258
|
],
|
|
249
|
-
commands: Object.keys(commands).filter((
|
|
250
|
-
).map((command5)=>`${command5} [options]`
|
|
251
|
-
),
|
|
259
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
252
260
|
options: sharedFlags
|
|
253
261
|
});
|
|
254
262
|
process.exit(1);
|
|
@@ -258,7 +266,7 @@ if (commands[command] === undefined) {
|
|
|
258
266
|
let { args: flags , run } = commands[command];
|
|
259
267
|
let args = (()=>{
|
|
260
268
|
try {
|
|
261
|
-
let result = (0, _arg
|
|
269
|
+
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
262
270
|
...flags,
|
|
263
271
|
...sharedFlags
|
|
264
272
|
}).filter(([_key, value])=>{
|
|
@@ -267,8 +275,7 @@ let args = (()=>{
|
|
|
267
275
|
}).map(([key, value])=>[
|
|
268
276
|
key,
|
|
269
277
|
typeof value === "object" ? value.type : value
|
|
270
|
-
]
|
|
271
|
-
)), {
|
|
278
|
+
])), {
|
|
272
279
|
permissive: true
|
|
273
280
|
});
|
|
274
281
|
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
@@ -283,16 +290,16 @@ let args = (()=>{
|
|
|
283
290
|
handler = flags[handler];
|
|
284
291
|
}
|
|
285
292
|
if (!handler) continue;
|
|
286
|
-
let
|
|
293
|
+
let args = [];
|
|
287
294
|
let offset = i + 1;
|
|
288
295
|
// Parse args for current flag
|
|
289
296
|
while(result["_"][offset] && !result["_"][offset].startsWith("-")){
|
|
290
|
-
|
|
297
|
+
args.push(result["_"][offset++]);
|
|
291
298
|
}
|
|
292
299
|
// Cleanup manually parsed flags + args
|
|
293
|
-
result["_"].splice(i, 1 +
|
|
300
|
+
result["_"].splice(i, 1 + args.length);
|
|
294
301
|
// Set the resolved value in the `result` object
|
|
295
|
-
result[flagName] = handler.type(
|
|
302
|
+
result[flagName] = handler.type(args.length === 0 ? undefined : args.length === 1 ? args[0] : args, flagName);
|
|
296
303
|
}
|
|
297
304
|
// Ensure that the `command` is always the first argument in the `args`.
|
|
298
305
|
// This is important so that we don't have to check if a default command
|
|
@@ -335,27 +342,23 @@ run();
|
|
|
335
342
|
function init() {
|
|
336
343
|
let messages = [];
|
|
337
344
|
var ref;
|
|
338
|
-
let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref :
|
|
345
|
+
let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref : `./${configs.tailwind}`);
|
|
339
346
|
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
340
347
|
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
341
348
|
} else {
|
|
342
349
|
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
|
-
}
|
|
347
350
|
// Change colors import
|
|
348
351
|
stubFile = stubFile.replace("../colors", "tailwindcss/colors");
|
|
349
352
|
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
|
|
350
353
|
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
351
354
|
}
|
|
352
355
|
if (args["--postcss"]) {
|
|
353
|
-
let postcssConfigLocation = _path.default.resolve(
|
|
356
|
+
let postcssConfigLocation = _path.default.resolve(`./${configs.postcss}`);
|
|
354
357
|
if (_fs.default.existsSync(postcssConfigLocation)) {
|
|
355
358
|
messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
|
|
356
359
|
} else {
|
|
357
|
-
let
|
|
358
|
-
_fs.default.writeFileSync(postcssConfigLocation,
|
|
360
|
+
let stubFile1 = _fs.default.readFileSync(_path.default.resolve(__dirname, "../stubs/defaultPostCssConfig.stub.js"), "utf8");
|
|
361
|
+
_fs.default.writeFileSync(postcssConfigLocation, stubFile1, "utf8");
|
|
359
362
|
messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
|
|
360
363
|
}
|
|
361
364
|
}
|
|
@@ -389,14 +392,13 @@ async function build() {
|
|
|
389
392
|
console.error(`Specified config file ${args["--config"]} does not exist.`);
|
|
390
393
|
process.exit(9);
|
|
391
394
|
}
|
|
392
|
-
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
|
|
393
|
-
)(_path.default.resolve("./tailwind.config.js"));
|
|
395
|
+
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
|
|
394
396
|
async function loadPostCssPlugins() {
|
|
395
397
|
let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
|
|
396
|
-
let
|
|
398
|
+
let config = customPostCssPath ? await (async ()=>{
|
|
397
399
|
let file = _path.default.resolve(customPostCssPath);
|
|
398
400
|
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
|
399
|
-
let { config ={} } = await (0, _lilconfig
|
|
401
|
+
let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
|
|
400
402
|
if (typeof config === "function") {
|
|
401
403
|
config = config();
|
|
402
404
|
} else {
|
|
@@ -407,11 +409,11 @@ async function build() {
|
|
|
407
409
|
}
|
|
408
410
|
return {
|
|
409
411
|
file,
|
|
410
|
-
plugins: (0, _plugins
|
|
411
|
-
options: (0, _options
|
|
412
|
+
plugins: (0, _plugins.default)(config, file),
|
|
413
|
+
options: (0, _options.default)(config, file)
|
|
412
414
|
};
|
|
413
|
-
})() : await (0, _postcssLoadConfig
|
|
414
|
-
let configPlugins =
|
|
415
|
+
})() : await (0, _postcssLoadConfig.default)();
|
|
416
|
+
let configPlugins = config.plugins;
|
|
415
417
|
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
416
418
|
if (typeof plugin === "function" && plugin.name === "tailwindcss") {
|
|
417
419
|
return true;
|
|
@@ -426,7 +428,44 @@ async function build() {
|
|
|
426
428
|
return [
|
|
427
429
|
beforePlugins,
|
|
428
430
|
afterPlugins,
|
|
429
|
-
|
|
431
|
+
config.options
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
function loadBuiltinPostcssPlugins() {
|
|
435
|
+
let postcss = loadPostcss();
|
|
436
|
+
let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
|
|
437
|
+
return [
|
|
438
|
+
[
|
|
439
|
+
(root)=>{
|
|
440
|
+
root.walkAtRules("import", (rule)=>{
|
|
441
|
+
if (rule.params.slice(1).startsWith("tailwindcss/")) {
|
|
442
|
+
rule.after(postcss.comment({
|
|
443
|
+
text: IMPORT_COMMENT + rule.params
|
|
444
|
+
}));
|
|
445
|
+
rule.remove();
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
},
|
|
449
|
+
(()=>{
|
|
450
|
+
try {
|
|
451
|
+
return require("postcss-import");
|
|
452
|
+
} catch {}
|
|
453
|
+
return (0, _indexJs.lazyPostcssImport)();
|
|
454
|
+
})(),
|
|
455
|
+
(root)=>{
|
|
456
|
+
root.walkComments((rule)=>{
|
|
457
|
+
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
|
458
|
+
rule.after(postcss.atRule({
|
|
459
|
+
name: "import",
|
|
460
|
+
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
461
|
+
}));
|
|
462
|
+
rule.remove();
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
[],
|
|
468
|
+
{},
|
|
430
469
|
];
|
|
431
470
|
}
|
|
432
471
|
function resolveConfig() {
|
|
@@ -442,15 +481,18 @@ async function build() {
|
|
|
442
481
|
}
|
|
443
482
|
if (args["--content"]) {
|
|
444
483
|
let files = args["--content"].split(/(?<!{[^}]+),/);
|
|
445
|
-
let resolvedConfig = (0, _resolveConfig
|
|
484
|
+
let resolvedConfig = (0, _resolveConfig.default)(config, {
|
|
446
485
|
content: {
|
|
447
486
|
files
|
|
448
487
|
}
|
|
449
488
|
});
|
|
450
489
|
resolvedConfig.content.files = files;
|
|
490
|
+
resolvedConfig = (0, _validateConfigJs.validateConfig)(resolvedConfig);
|
|
451
491
|
return resolvedConfig;
|
|
452
492
|
}
|
|
453
|
-
|
|
493
|
+
let resolvedConfig1 = (0, _resolveConfig.default)(config);
|
|
494
|
+
resolvedConfig1 = (0, _validateConfigJs.validateConfig)(resolvedConfig1);
|
|
495
|
+
return resolvedConfig1;
|
|
454
496
|
}
|
|
455
497
|
function extractFileGlobs(config) {
|
|
456
498
|
return config.content.files.filter((file)=>{
|
|
@@ -458,8 +500,7 @@ async function build() {
|
|
|
458
500
|
// like an object it's probably a raw content object. But this object
|
|
459
501
|
// is not watchable, so let's remove it.
|
|
460
502
|
return typeof file === "string";
|
|
461
|
-
}).map((glob)=>(0, _normalizePath
|
|
462
|
-
);
|
|
503
|
+
}).map((glob)=>(0, _normalizePath.default)(glob));
|
|
463
504
|
}
|
|
464
505
|
function extractRawContent(config) {
|
|
465
506
|
return config.content.files.filter((file)=>{
|
|
@@ -493,7 +534,7 @@ async function build() {
|
|
|
493
534
|
return {
|
|
494
535
|
postcssPlugin: "tailwindcss",
|
|
495
536
|
Once (root, { result }) {
|
|
496
|
-
(0, _processTailwindFeatures
|
|
537
|
+
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
497
538
|
return ()=>{
|
|
498
539
|
return createContext(config, changedContent);
|
|
499
540
|
};
|
|
@@ -502,11 +543,7 @@ async function build() {
|
|
|
502
543
|
};
|
|
503
544
|
};
|
|
504
545
|
tailwindPlugin.postcss = true;
|
|
505
|
-
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() :
|
|
506
|
-
[],
|
|
507
|
-
[],
|
|
508
|
-
{}
|
|
509
|
-
];
|
|
546
|
+
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
510
547
|
let plugins = [
|
|
511
548
|
...beforePlugins,
|
|
512
549
|
tailwindPlugin,
|
|
@@ -517,7 +554,7 @@ async function build() {
|
|
|
517
554
|
try {
|
|
518
555
|
return require("autoprefixer");
|
|
519
556
|
} catch {}
|
|
520
|
-
return (0, _indexJs
|
|
557
|
+
return (0, _indexJs.lazyAutoprefixer)();
|
|
521
558
|
})(),
|
|
522
559
|
args["--minify"] && (()=>{
|
|
523
560
|
let options = {
|
|
@@ -532,7 +569,7 @@ async function build() {
|
|
|
532
569
|
try {
|
|
533
570
|
return require("cssnano");
|
|
534
571
|
} catch {}
|
|
535
|
-
return (0, _indexJs
|
|
572
|
+
return (0, _indexJs.lazyCssnano)()(options);
|
|
536
573
|
})(),
|
|
537
574
|
].filter(Boolean);
|
|
538
575
|
let postcss = loadPostcss();
|
|
@@ -541,13 +578,11 @@ async function build() {
|
|
|
541
578
|
let start = process.hrtime.bigint();
|
|
542
579
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
543
580
|
recursive: true
|
|
544
|
-
}) : null
|
|
545
|
-
).then(()=>processor.process(css, {
|
|
581
|
+
}) : null).then(()=>processor.process(css, {
|
|
546
582
|
...postcssOptions,
|
|
547
583
|
from: input,
|
|
548
584
|
to: output
|
|
549
|
-
})
|
|
550
|
-
).then((result)=>{
|
|
585
|
+
})).then((result)=>{
|
|
551
586
|
if (!output) {
|
|
552
587
|
return process.stdout.write(result.css);
|
|
553
588
|
}
|
|
@@ -558,10 +593,10 @@ async function build() {
|
|
|
558
593
|
}).then(()=>{
|
|
559
594
|
let end = process.hrtime.bigint();
|
|
560
595
|
console.error();
|
|
561
|
-
console.error("Done in", (end - start) / BigInt(
|
|
596
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
562
597
|
});
|
|
563
598
|
}
|
|
564
|
-
let
|
|
599
|
+
let css = await (()=>{
|
|
565
600
|
// Piping in data, let's drain the stdin
|
|
566
601
|
if (input === "-") {
|
|
567
602
|
return drainStdin();
|
|
@@ -573,7 +608,7 @@ async function build() {
|
|
|
573
608
|
// No input file provided, fallback to default atrules
|
|
574
609
|
return "@tailwind base; @tailwind components; @tailwind utilities";
|
|
575
610
|
})();
|
|
576
|
-
return processCSS(
|
|
611
|
+
return processCSS(css);
|
|
577
612
|
}
|
|
578
613
|
let context = null;
|
|
579
614
|
async function startWatcher() {
|
|
@@ -583,12 +618,11 @@ async function build() {
|
|
|
583
618
|
let watcher = null;
|
|
584
619
|
function refreshConfig() {
|
|
585
620
|
env.DEBUG && console.time("Module dependencies");
|
|
586
|
-
for (let
|
|
587
|
-
delete require.cache[require.resolve(
|
|
621
|
+
for (let file of configDependencies){
|
|
622
|
+
delete require.cache[require.resolve(file)];
|
|
588
623
|
}
|
|
589
624
|
if (configPath) {
|
|
590
|
-
configDependencies = (0, _getModuleDependencies
|
|
591
|
-
);
|
|
625
|
+
configDependencies = (0, _getModuleDependencies.default)(configPath).map(({ file })=>file);
|
|
592
626
|
for (let dependency of configDependencies){
|
|
593
627
|
contextDependencies.add(dependency);
|
|
594
628
|
}
|
|
@@ -596,10 +630,7 @@ async function build() {
|
|
|
596
630
|
env.DEBUG && console.timeEnd("Module dependencies");
|
|
597
631
|
return resolveConfig();
|
|
598
632
|
}
|
|
599
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() :
|
|
600
|
-
[],
|
|
601
|
-
[]
|
|
602
|
-
];
|
|
633
|
+
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
603
634
|
let plugins = [
|
|
604
635
|
...beforePlugins,
|
|
605
636
|
"__TAILWIND_PLUGIN_POSITION__",
|
|
@@ -610,7 +641,7 @@ async function build() {
|
|
|
610
641
|
try {
|
|
611
642
|
return require("autoprefixer");
|
|
612
643
|
} catch {}
|
|
613
|
-
return (0, _indexJs
|
|
644
|
+
return (0, _indexJs.lazyAutoprefixer)();
|
|
614
645
|
})(),
|
|
615
646
|
args["--minify"] && (()=>{
|
|
616
647
|
let options = {
|
|
@@ -625,7 +656,7 @@ async function build() {
|
|
|
625
656
|
try {
|
|
626
657
|
return require("cssnano");
|
|
627
658
|
} catch {}
|
|
628
|
-
return (0, _indexJs
|
|
659
|
+
return (0, _indexJs.lazyCssnano)()(options);
|
|
629
660
|
})(),
|
|
630
661
|
].filter(Boolean);
|
|
631
662
|
async function rebuild(config) {
|
|
@@ -635,7 +666,7 @@ async function build() {
|
|
|
635
666
|
postcssPlugin: "tailwindcss",
|
|
636
667
|
Once (root, { result }) {
|
|
637
668
|
env.DEBUG && console.time("Compiling CSS");
|
|
638
|
-
(0, _processTailwindFeatures
|
|
669
|
+
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
639
670
|
console.error();
|
|
640
671
|
console.error("Rebuilding...");
|
|
641
672
|
return ()=>{
|
|
@@ -663,12 +694,10 @@ async function build() {
|
|
|
663
694
|
let start = process.hrtime.bigint();
|
|
664
695
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
665
696
|
recursive: true
|
|
666
|
-
}) : null
|
|
667
|
-
).then(()=>processor.process(css, {
|
|
697
|
+
}) : null).then(()=>processor.process(css, {
|
|
668
698
|
from: input,
|
|
669
699
|
to: output
|
|
670
|
-
})
|
|
671
|
-
).then(async (result)=>{
|
|
700
|
+
})).then(async (result)=>{
|
|
672
701
|
for (let message of result.messages){
|
|
673
702
|
if (message.type === "dependency") {
|
|
674
703
|
contextDependencies.add(message.file);
|
|
@@ -686,7 +715,7 @@ async function build() {
|
|
|
686
715
|
].filter(Boolean));
|
|
687
716
|
}).then(()=>{
|
|
688
717
|
let end = process.hrtime.bigint();
|
|
689
|
-
console.error("Done in", (end - start) / BigInt(
|
|
718
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
690
719
|
}).catch((err)=>{
|
|
691
720
|
if (err.name === "CssSyntaxError") {
|
|
692
721
|
console.error(err.toString());
|
|
@@ -695,7 +724,7 @@ async function build() {
|
|
|
695
724
|
}
|
|
696
725
|
});
|
|
697
726
|
}
|
|
698
|
-
let
|
|
727
|
+
let css = await (()=>{
|
|
699
728
|
// Piping in data, let's drain the stdin
|
|
700
729
|
if (input === "-") {
|
|
701
730
|
return drainStdin();
|
|
@@ -707,17 +736,17 @@ async function build() {
|
|
|
707
736
|
// No input file provided, fallback to default atrules
|
|
708
737
|
return "@tailwind base; @tailwind components; @tailwind utilities";
|
|
709
738
|
})();
|
|
710
|
-
let
|
|
739
|
+
let result = await processCSS(css);
|
|
711
740
|
env.DEBUG && console.timeEnd("Finished in");
|
|
712
|
-
return
|
|
741
|
+
return result;
|
|
713
742
|
}
|
|
714
|
-
let
|
|
743
|
+
let config = refreshConfig(configPath);
|
|
715
744
|
if (input) {
|
|
716
745
|
contextDependencies.add(_path.default.resolve(input));
|
|
717
746
|
}
|
|
718
747
|
watcher = _chokidar.default.watch([
|
|
719
748
|
...contextDependencies,
|
|
720
|
-
...extractFileGlobs(
|
|
749
|
+
...extractFileGlobs(config)
|
|
721
750
|
], {
|
|
722
751
|
usePolling: shouldPoll,
|
|
723
752
|
interval: shouldPoll ? pollInterval : undefined,
|
|
@@ -732,16 +761,16 @@ async function build() {
|
|
|
732
761
|
if (contextDependencies.has(file)) {
|
|
733
762
|
env.DEBUG && console.time("Resolve config");
|
|
734
763
|
context = null;
|
|
735
|
-
|
|
764
|
+
config = refreshConfig(configPath);
|
|
736
765
|
env.DEBUG && console.timeEnd("Resolve config");
|
|
737
766
|
env.DEBUG && console.time("Watch new files");
|
|
738
|
-
let globs = extractFileGlobs(
|
|
767
|
+
let globs = extractFileGlobs(config);
|
|
739
768
|
watcher.add(configDependencies);
|
|
740
769
|
watcher.add(globs);
|
|
741
770
|
env.DEBUG && console.timeEnd("Watch new files");
|
|
742
771
|
chain = chain.then(async ()=>{
|
|
743
|
-
changedContent.push(...getChangedContent(
|
|
744
|
-
await rebuild(
|
|
772
|
+
changedContent.push(...getChangedContent(config));
|
|
773
|
+
await rebuild(config);
|
|
745
774
|
});
|
|
746
775
|
} else {
|
|
747
776
|
chain = chain.then(async ()=>{
|
|
@@ -749,7 +778,7 @@ async function build() {
|
|
|
749
778
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
750
779
|
extension: _path.default.extname(file).slice(1)
|
|
751
780
|
});
|
|
752
|
-
await rebuild(
|
|
781
|
+
await rebuild(config);
|
|
753
782
|
});
|
|
754
783
|
}
|
|
755
784
|
});
|
|
@@ -759,18 +788,19 @@ async function build() {
|
|
|
759
788
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
760
789
|
extension: _path.default.extname(file).slice(1)
|
|
761
790
|
});
|
|
762
|
-
await rebuild(
|
|
791
|
+
await rebuild(config);
|
|
763
792
|
});
|
|
764
793
|
});
|
|
765
794
|
chain = chain.then(()=>{
|
|
766
|
-
changedContent.push(...getChangedContent(
|
|
767
|
-
return rebuild(
|
|
795
|
+
changedContent.push(...getChangedContent(config));
|
|
796
|
+
return rebuild(config);
|
|
768
797
|
});
|
|
769
798
|
}
|
|
770
799
|
if (shouldWatch) {
|
|
771
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.
|
|
772
|
-
|
|
773
|
-
|
|
800
|
+
/* Abort the watcher if stdin is closed to avoid zombie processes */ if (process.stdin.isTTY) {
|
|
801
|
+
process.stdin.on("end", ()=>process.exit(0));
|
|
802
|
+
process.stdin.resume();
|
|
803
|
+
}
|
|
774
804
|
startWatcher();
|
|
775
805
|
} else {
|
|
776
806
|
buildOnce();
|
package/lib/constants.js
CHANGED
|
@@ -2,36 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
var
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
cli: ()=>cli,
|
|
13
|
+
defaultConfigFile: ()=>defaultConfigFile,
|
|
14
|
+
defaultPostCssConfigFile: ()=>defaultPostCssConfigFile,
|
|
15
|
+
cjsConfigFile: ()=>cjsConfigFile,
|
|
16
|
+
cjsPostCssConfigFile: ()=>cjsPostCssConfigFile,
|
|
17
|
+
supportedConfigFiles: ()=>supportedConfigFiles,
|
|
18
|
+
supportedPostCssConfigFile: ()=>supportedPostCssConfigFile,
|
|
19
|
+
defaultConfigStubFile: ()=>defaultConfigStubFile,
|
|
20
|
+
simpleConfigStubFile: ()=>simpleConfigStubFile,
|
|
21
|
+
defaultPostCssConfigStubFile: ()=>defaultPostCssConfigStubFile
|
|
22
|
+
});
|
|
23
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
7
24
|
function _interopRequireDefault(obj) {
|
|
8
25
|
return obj && obj.__esModule ? obj : {
|
|
9
26
|
default: obj
|
|
10
27
|
};
|
|
11
28
|
}
|
|
12
29
|
const cli = "tailwind";
|
|
13
|
-
exports.cli = cli;
|
|
14
30
|
const defaultConfigFile = "./tailwind.config.js";
|
|
15
|
-
exports.defaultConfigFile = defaultConfigFile;
|
|
16
31
|
const defaultPostCssConfigFile = "./postcss.config.js";
|
|
17
|
-
exports.defaultPostCssConfigFile = defaultPostCssConfigFile;
|
|
18
32
|
const cjsConfigFile = "./tailwind.config.cjs";
|
|
19
|
-
exports.cjsConfigFile = cjsConfigFile;
|
|
20
33
|
const cjsPostCssConfigFile = "./postcss.config.cjs";
|
|
21
|
-
exports.cjsPostCssConfigFile = cjsPostCssConfigFile;
|
|
22
34
|
const supportedConfigFiles = [
|
|
23
35
|
cjsConfigFile,
|
|
24
36
|
defaultConfigFile
|
|
25
37
|
];
|
|
26
|
-
exports.supportedConfigFiles = supportedConfigFiles;
|
|
27
38
|
const supportedPostCssConfigFile = [
|
|
28
39
|
cjsPostCssConfigFile,
|
|
29
40
|
defaultPostCssConfigFile
|
|
30
41
|
];
|
|
31
|
-
exports.supportedPostCssConfigFile = supportedPostCssConfigFile;
|
|
32
42
|
const defaultConfigStubFile = _path.default.resolve(__dirname, "../stubs/defaultConfig.stub.js");
|
|
33
|
-
exports.defaultConfigStubFile = defaultConfigStubFile;
|
|
34
43
|
const simpleConfigStubFile = _path.default.resolve(__dirname, "../stubs/simpleConfig.stub.js");
|
|
35
|
-
exports.simpleConfigStubFile = simpleConfigStubFile;
|
|
36
44
|
const defaultPostCssConfigStubFile = _path.default.resolve(__dirname, "../stubs/defaultPostCssConfig.stub.js");
|
|
37
|
-
exports.defaultPostCssConfigStubFile = defaultPostCssConfigStubFile;
|