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