tailwindcss 0.0.0-insiders.c834da4 → 0.0.0-insiders.c8bf2d4
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/README.md +1 -1
- package/lib/cli/build/plugin.js +30 -25
- package/lib/cli/index.js +231 -10
- package/lib/cli.js +4 -236
- package/lib/corePluginList.js +2 -0
- package/lib/corePlugins.js +216 -4
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +5 -1
- package/lib/index.js +4 -46
- package/lib/lib/content.js +16 -16
- package/lib/lib/defaultExtractor.js +7 -2
- package/lib/lib/detectNesting.js +7 -1
- package/lib/lib/expandTailwindAtRules.js +30 -5
- package/lib/lib/generateRules.js +92 -56
- package/lib/lib/offsets.js +19 -0
- package/lib/lib/setupContextUtils.js +84 -37
- package/lib/lib/setupTrackingContext.js +25 -4
- package/lib/lib/sharedState.js +19 -1
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +47 -0
- package/lib/oxide/cli/build/plugin.js +364 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +220 -0
- package/lib/oxide/cli/init/index.js +35 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/lib/util/color.js +16 -2
- package/lib/util/dataTypes.js +19 -1
- package/lib/util/formatVariantSelector.js +151 -103
- package/lib/util/negateValue.js +2 -2
- package/lib/util/pluginUtils.js +5 -24
- package/lib/util/prefixSelector.js +22 -8
- package/package.json +26 -15
- package/peers/index.js +108 -173
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/plugin.js +12 -7
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -231
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +117 -4
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +4 -0
- package/src/index.js +4 -46
- package/src/lib/content.js +12 -17
- package/src/lib/defaultExtractor.js +8 -2
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/generateRules.js +106 -56
- package/src/lib/offsets.js +22 -0
- package/src/lib/setupContextUtils.js +90 -41
- package/src/lib/setupTrackingContext.js +31 -6
- package/src/lib/sharedState.js +17 -0
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +436 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +212 -0
- package/src/oxide/cli/init/index.ts +32 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +18 -0
- package/src/util/formatVariantSelector.js +204 -122
- package/src/util/negateValue.js +1 -1
- package/src/util/pluginUtils.js +10 -29
- package/src/util/prefixSelector.js +28 -10
- package/stubs/defaultConfig.stub.js +3 -0
- package/types/config.d.ts +11 -1
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +5 -2
- package/CHANGELOG.md +0 -2352
- package/lib/cli/shared.js +0 -12
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
|
-
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/workflow/status/tailwindlabs/tailwindcss/
|
|
17
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci-stable.yml?branch=master" alt="Build Status"></a>
|
|
18
18
|
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
|
19
19
|
<a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
|
20
20
|
<a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
package/lib/cli/build/plugin.js
CHANGED
|
@@ -18,7 +18,7 @@ const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-conf
|
|
|
18
18
|
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("../../processTailwindFeatures"));
|
|
19
19
|
const _deps = require("./deps");
|
|
20
20
|
const _utils = require("./utils");
|
|
21
|
-
const
|
|
21
|
+
const _sharedState = require("../../lib/sharedState");
|
|
22
22
|
const _resolveConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../../../resolveConfig.js"));
|
|
23
23
|
const _getModuleDependenciesJs = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies.js"));
|
|
24
24
|
const _contentJs = require("../../lib/content.js");
|
|
@@ -143,7 +143,7 @@ let state = {
|
|
|
143
143
|
return config;
|
|
144
144
|
},
|
|
145
145
|
refreshConfigDependencies (configPath) {
|
|
146
|
-
|
|
146
|
+
_sharedState.env.DEBUG && console.time("Module dependencies");
|
|
147
147
|
for (let file of this.configDependencies){
|
|
148
148
|
delete require.cache[require.resolve(file)];
|
|
149
149
|
}
|
|
@@ -153,7 +153,7 @@ let state = {
|
|
|
153
153
|
this.configDependencies.add(dependency);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
_sharedState.env.DEBUG && console.timeEnd("Module dependencies");
|
|
157
157
|
},
|
|
158
158
|
readContentPaths () {
|
|
159
159
|
let content = [];
|
|
@@ -161,10 +161,17 @@ let state = {
|
|
|
161
161
|
// TODO: When we make the postcss plugin async-capable this can become async
|
|
162
162
|
let files = _fastGlob.default.sync(this.contentPatterns.all);
|
|
163
163
|
for (let file of files){
|
|
164
|
-
|
|
165
|
-
content
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
if (_sharedState.env.OXIDE) {
|
|
165
|
+
content.push({
|
|
166
|
+
file,
|
|
167
|
+
extension: _path.default.extname(file).slice(1)
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
content.push({
|
|
171
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
172
|
+
extension: _path.default.extname(file).slice(1)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
168
175
|
}
|
|
169
176
|
// Resolve raw content in the tailwind config
|
|
170
177
|
let rawContent = this.config.content.files.filter((file)=>{
|
|
@@ -183,32 +190,30 @@ let state = {
|
|
|
183
190
|
this.context.changedContent = this.changedContent.splice(0);
|
|
184
191
|
return this.context;
|
|
185
192
|
}
|
|
186
|
-
|
|
193
|
+
_sharedState.env.DEBUG && console.time("Searching for config");
|
|
187
194
|
var _findAtConfigPath;
|
|
188
195
|
let configPath = (_findAtConfigPath = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) !== null && _findAtConfigPath !== void 0 ? _findAtConfigPath : cliConfigPath;
|
|
189
|
-
|
|
190
|
-
|
|
196
|
+
_sharedState.env.DEBUG && console.timeEnd("Searching for config");
|
|
197
|
+
_sharedState.env.DEBUG && console.time("Loading config");
|
|
191
198
|
let config = this.loadConfig(configPath, content);
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
_sharedState.env.DEBUG && console.timeEnd("Loading config");
|
|
200
|
+
_sharedState.env.DEBUG && console.time("Creating context");
|
|
194
201
|
this.context = createContext(config, []);
|
|
195
202
|
Object.assign(this.context, {
|
|
196
203
|
userConfigPath: configPath
|
|
197
204
|
});
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
_sharedState.env.DEBUG && console.timeEnd("Creating context");
|
|
206
|
+
_sharedState.env.DEBUG && console.time("Resolving content paths");
|
|
200
207
|
this.refreshContentPaths();
|
|
201
|
-
|
|
208
|
+
_sharedState.env.DEBUG && console.timeEnd("Resolving content paths");
|
|
202
209
|
if (this.watcher) {
|
|
203
|
-
|
|
210
|
+
_sharedState.env.DEBUG && console.time("Watch new files");
|
|
204
211
|
this.watcher.refreshWatchedFiles();
|
|
205
|
-
|
|
212
|
+
_sharedState.env.DEBUG && console.timeEnd("Watch new files");
|
|
206
213
|
}
|
|
207
|
-
_shared.env.DEBUG && console.time("Reading content files");
|
|
208
214
|
for (let file of this.readContentPaths()){
|
|
209
215
|
this.context.changedContent.push(file);
|
|
210
216
|
}
|
|
211
|
-
_shared.env.DEBUG && console.timeEnd("Reading content files");
|
|
212
217
|
return this.context;
|
|
213
218
|
}
|
|
214
219
|
};
|
|
@@ -235,7 +240,7 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
235
240
|
return {
|
|
236
241
|
postcssPlugin: "tailwindcss",
|
|
237
242
|
Once (root, { result }) {
|
|
238
|
-
|
|
243
|
+
_sharedState.env.DEBUG && console.time("Compiling CSS");
|
|
239
244
|
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
240
245
|
console.error();
|
|
241
246
|
console.error("Rebuilding...");
|
|
@@ -249,7 +254,7 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
249
254
|
});
|
|
250
255
|
};
|
|
251
256
|
})(root, result);
|
|
252
|
-
|
|
257
|
+
_sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
|
|
253
258
|
}
|
|
254
259
|
};
|
|
255
260
|
};
|
|
@@ -286,17 +291,17 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
286
291
|
if (!state.watcher) {
|
|
287
292
|
return result;
|
|
288
293
|
}
|
|
289
|
-
|
|
294
|
+
_sharedState.env.DEBUG && console.time("Recording PostCSS dependencies");
|
|
290
295
|
for (let message of result.messages){
|
|
291
296
|
if (message.type === "dependency") {
|
|
292
297
|
state.contextDependencies.add(message.file);
|
|
293
298
|
}
|
|
294
299
|
}
|
|
295
|
-
|
|
300
|
+
_sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
|
|
296
301
|
// TODO: This needs to be in a different spot
|
|
297
|
-
|
|
302
|
+
_sharedState.env.DEBUG && console.time("Watch new files");
|
|
298
303
|
state.watcher.refreshWatchedFiles();
|
|
299
|
-
|
|
304
|
+
_sharedState.env.DEBUG && console.timeEnd("Watch new files");
|
|
300
305
|
return result;
|
|
301
306
|
}).then((result)=>{
|
|
302
307
|
if (!output) {
|
package/lib/cli/index.js
CHANGED
|
@@ -1,18 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
Object.defineProperty(exports, "__esModule", {
|
|
3
4
|
value: true
|
|
4
5
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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("./build");
|
|
10
|
+
const _help = require("./help");
|
|
11
|
+
const _init = require("./init");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
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;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
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
|
+
// ---
|
|
34
|
+
function oneOf(...options) {
|
|
35
|
+
return Object.assign((value = true)=>{
|
|
36
|
+
for (let option of options){
|
|
37
|
+
let parsed = option(value);
|
|
38
|
+
if (parsed === value) {
|
|
39
|
+
return parsed;
|
|
14
40
|
}
|
|
41
|
+
}
|
|
42
|
+
throw new Error("...");
|
|
43
|
+
}, {
|
|
44
|
+
manualParsing: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
let commands = {
|
|
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
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
let sharedFlags = {
|
|
116
|
+
"--help": {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
description: "Display usage information"
|
|
119
|
+
},
|
|
120
|
+
"-h": "--help"
|
|
121
|
+
};
|
|
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
|
+
}
|
|
133
|
+
});
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}
|
|
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";
|
|
142
|
+
} else {
|
|
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);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
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 _value_type;
|
|
163
|
+
return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.manualParsing);
|
|
164
|
+
}).map(([key, value])=>[
|
|
165
|
+
key,
|
|
166
|
+
typeof value === "object" ? value.type : value
|
|
167
|
+
])), {
|
|
168
|
+
permissive: true
|
|
15
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);
|
|
202
|
+
}
|
|
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);
|
|
211
|
+
}
|
|
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);
|
|
223
|
+
}
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
226
|
+
})();
|
|
227
|
+
if (args["--help"]) {
|
|
228
|
+
(0, _help.help)({
|
|
229
|
+
options: {
|
|
230
|
+
...flags,
|
|
231
|
+
...sharedFlags
|
|
232
|
+
},
|
|
233
|
+
usage: [
|
|
234
|
+
`tailwindcss ${command} [options]`
|
|
235
|
+
]
|
|
16
236
|
});
|
|
17
|
-
|
|
237
|
+
process.exit(0);
|
|
18
238
|
}
|
|
239
|
+
run(args, configs);
|
package/lib/cli.js
CHANGED
|
@@ -1,239 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
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
|
-
};
|
|
3
|
+
if (process.env.OXIDE) {
|
|
4
|
+
module.exports = require("./oxide/cli");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./cli/index");
|
|
16
7
|
}
|
|
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;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
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
|
-
// ---
|
|
34
|
-
function oneOf(...options) {
|
|
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
|
-
});
|
|
46
|
-
}
|
|
47
|
-
let commands = {
|
|
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
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
let sharedFlags = {
|
|
116
|
-
"--help": {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
description: "Display usage information"
|
|
119
|
-
},
|
|
120
|
-
"-h": "--help"
|
|
121
|
-
};
|
|
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
|
-
}
|
|
133
|
-
});
|
|
134
|
-
process.exit(0);
|
|
135
|
-
}
|
|
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";
|
|
142
|
-
} else {
|
|
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);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
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 _value_type;
|
|
163
|
-
return !(value === null || value === void 0 ? void 0 : (_value_type = value.type) === null || _value_type === void 0 ? void 0 : _value_type.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);
|
|
202
|
-
}
|
|
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);
|
|
211
|
-
}
|
|
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);
|
|
223
|
-
}
|
|
224
|
-
throw err;
|
|
225
|
-
}
|
|
226
|
-
})();
|
|
227
|
-
if (args["--help"]) {
|
|
228
|
-
(0, _help.help)({
|
|
229
|
-
options: {
|
|
230
|
-
...flags,
|
|
231
|
-
...sharedFlags
|
|
232
|
-
},
|
|
233
|
-
usage: [
|
|
234
|
-
`tailwindcss ${command} [options]`
|
|
235
|
-
]
|
|
236
|
-
});
|
|
237
|
-
process.exit(0);
|
|
238
|
-
}
|
|
239
|
-
run(args, configs);
|
package/lib/corePluginList.js
CHANGED
|
@@ -40,6 +40,7 @@ const _default = [
|
|
|
40
40
|
"flexGrow",
|
|
41
41
|
"flexBasis",
|
|
42
42
|
"tableLayout",
|
|
43
|
+
"captionSide",
|
|
43
44
|
"borderCollapse",
|
|
44
45
|
"borderSpacing",
|
|
45
46
|
"transformOrigin",
|
|
@@ -91,6 +92,7 @@ const _default = [
|
|
|
91
92
|
"overscrollBehavior",
|
|
92
93
|
"scrollBehavior",
|
|
93
94
|
"textOverflow",
|
|
95
|
+
"hyphens",
|
|
94
96
|
"whitespace",
|
|
95
97
|
"wordBreak",
|
|
96
98
|
"borderRadius",
|