tailwindcss 0.0.0-oxide-insiders.0ddc71e → 0.0.0-oxide-insiders.2f21b22
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/index.css +5 -0
- package/lib/cli/build/plugin.js +10 -5
- package/lib/cli/init/index.js +4 -0
- package/lib/css/preflight.css +7 -1
- package/lib/lib/content.js +23 -2
- package/lib/lib/evaluateTailwindFunctions.js +5 -3
- package/lib/oxide/cli/build/plugin.js +10 -5
- package/lib/oxide/cli/init/index.js +4 -0
- package/lib/util/dataTypes.js +14 -6
- package/lib/util/getAllConfigs.js +3 -1
- package/lib/util/normalizeConfig.js +30 -8
- package/lib/util/validateConfig.js +7 -1
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/package.json +2 -2
- package/src/cli/build/plugin.js +8 -1
- package/src/cli/init/index.js +5 -0
- package/src/css/preflight.css +7 -1
- package/src/lib/content.js +31 -4
- package/src/lib/evaluateTailwindFunctions.js +4 -1
- package/src/oxide/cli/build/plugin.ts +8 -1
- package/src/oxide/cli/init/index.ts +5 -0
- package/src/util/dataTypes.js +17 -6
- package/src/util/getAllConfigs.js +8 -1
- package/src/util/normalizeConfig.js +51 -17
- package/src/util/validateConfig.js +8 -1
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/config.full.js +1 -0
- package/types/generated/default-theme.d.ts +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function stringifyNode(node, custom) {
|
|
3
|
+
var type = node.type;
|
|
4
|
+
var value = node.value;
|
|
5
|
+
var buf;
|
|
6
|
+
var customResult;
|
|
7
|
+
if (custom && (customResult = custom(node)) !== undefined) {
|
|
8
|
+
return customResult;
|
|
9
|
+
} else if (type === "word" || type === "space") {
|
|
10
|
+
return value;
|
|
11
|
+
} else if (type === "string") {
|
|
12
|
+
buf = node.quote || "";
|
|
13
|
+
return buf + value + (node.unclosed ? "" : buf);
|
|
14
|
+
} else if (type === "comment") {
|
|
15
|
+
return "/*" + value + (node.unclosed ? "" : "*/");
|
|
16
|
+
} else if (type === "div") {
|
|
17
|
+
return (node.before || "") + value + (node.after || "");
|
|
18
|
+
} else if (Array.isArray(node.nodes)) {
|
|
19
|
+
buf = stringify(node.nodes, custom);
|
|
20
|
+
if (type !== "function") {
|
|
21
|
+
return buf;
|
|
22
|
+
}
|
|
23
|
+
return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")");
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function stringify(nodes, custom) {
|
|
28
|
+
var result, i;
|
|
29
|
+
if (Array.isArray(nodes)) {
|
|
30
|
+
result = "";
|
|
31
|
+
for(i = nodes.length - 1; ~i; i -= 1){
|
|
32
|
+
result = stringifyNode(nodes[i], custom) + result;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
return stringifyNode(nodes, custom);
|
|
37
|
+
}
|
|
38
|
+
module.exports = stringify;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var minus = "-".charCodeAt(0);
|
|
3
|
+
var plus = "+".charCodeAt(0);
|
|
4
|
+
var dot = ".".charCodeAt(0);
|
|
5
|
+
var exp = "e".charCodeAt(0);
|
|
6
|
+
var EXP = "E".charCodeAt(0);
|
|
7
|
+
// Check if three code points would start a number
|
|
8
|
+
// https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
|
|
9
|
+
function likeNumber(value) {
|
|
10
|
+
var code = value.charCodeAt(0);
|
|
11
|
+
var nextCode;
|
|
12
|
+
if (code === plus || code === minus) {
|
|
13
|
+
nextCode = value.charCodeAt(1);
|
|
14
|
+
if (nextCode >= 48 && nextCode <= 57) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
var nextNextCode = value.charCodeAt(2);
|
|
18
|
+
if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (code === dot) {
|
|
24
|
+
nextCode = value.charCodeAt(1);
|
|
25
|
+
if (nextCode >= 48 && nextCode <= 57) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (code >= 48 && code <= 57) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
// Consume a number
|
|
36
|
+
// https://www.w3.org/TR/css-syntax-3/#consume-number
|
|
37
|
+
module.exports = function(value) {
|
|
38
|
+
var pos = 0;
|
|
39
|
+
var length = value.length;
|
|
40
|
+
var code;
|
|
41
|
+
var nextCode;
|
|
42
|
+
var nextNextCode;
|
|
43
|
+
if (length === 0 || !likeNumber(value)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
code = value.charCodeAt(pos);
|
|
47
|
+
if (code === plus || code === minus) {
|
|
48
|
+
pos++;
|
|
49
|
+
}
|
|
50
|
+
while(pos < length){
|
|
51
|
+
code = value.charCodeAt(pos);
|
|
52
|
+
if (code < 48 || code > 57) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
pos += 1;
|
|
56
|
+
}
|
|
57
|
+
code = value.charCodeAt(pos);
|
|
58
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
59
|
+
if (code === dot && nextCode >= 48 && nextCode <= 57) {
|
|
60
|
+
pos += 2;
|
|
61
|
+
while(pos < length){
|
|
62
|
+
code = value.charCodeAt(pos);
|
|
63
|
+
if (code < 48 || code > 57) {
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
pos += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
code = value.charCodeAt(pos);
|
|
70
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
71
|
+
nextNextCode = value.charCodeAt(pos + 2);
|
|
72
|
+
if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) {
|
|
73
|
+
pos += nextCode === plus || nextCode === minus ? 3 : 2;
|
|
74
|
+
while(pos < length){
|
|
75
|
+
code = value.charCodeAt(pos);
|
|
76
|
+
if (code < 48 || code > 57) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
pos += 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
number: value.slice(0, pos),
|
|
84
|
+
unit: value.slice(pos)
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function walk(nodes, cb, bubble) {
|
|
3
|
+
var i, max, node, result;
|
|
4
|
+
for(i = 0, max = nodes.length; i < max; i += 1){
|
|
5
|
+
node = nodes[i];
|
|
6
|
+
if (!bubble) {
|
|
7
|
+
result = cb(node, i, nodes);
|
|
8
|
+
}
|
|
9
|
+
if (result !== false && node.type === "function" && Array.isArray(node.nodes)) {
|
|
10
|
+
walk(node.nodes, cb, bubble);
|
|
11
|
+
}
|
|
12
|
+
if (bubble) {
|
|
13
|
+
cb(node, i, nodes);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss",
|
|
3
|
-
"version": "0.0.0-oxide-insiders.
|
|
3
|
+
"version": "0.0.0-oxide-insiders.2f21b22",
|
|
4
4
|
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@alloc/quick-lru": "^5.2.0",
|
|
71
|
-
"@tailwindcss/oxide": "0.0.0-oxide-insiders.
|
|
71
|
+
"@tailwindcss/oxide": "0.0.0-oxide-insiders.2f21b22",
|
|
72
72
|
"arg": "^5.0.2",
|
|
73
73
|
"browserslist": "^4.21.5",
|
|
74
74
|
"chokidar": "^3.5.3",
|
package/src/cli/build/plugin.js
CHANGED
|
@@ -19,6 +19,7 @@ import { findAtConfigPath } from '../../lib/findAtConfigPath.js'
|
|
|
19
19
|
import log from '../../util/log'
|
|
20
20
|
import { loadConfig } from '../../lib/load-config'
|
|
21
21
|
import getModuleDependencies from '../../lib/getModuleDependencies'
|
|
22
|
+
import { validateConfig } from '../../util/validateConfig'
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
*
|
|
@@ -161,7 +162,13 @@ let state = {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
// @ts-ignore
|
|
164
|
-
|
|
165
|
+
if (__OXIDE__) {
|
|
166
|
+
this.configBag.config = validateConfig(resolveConfig(this.configBag.config))
|
|
167
|
+
} else {
|
|
168
|
+
this.configBag.config = validateConfig(
|
|
169
|
+
resolveConfig(this.configBag.config, { content: { files: [] } })
|
|
170
|
+
)
|
|
171
|
+
}
|
|
165
172
|
|
|
166
173
|
// Override content files if `--content` has been passed explicitly
|
|
167
174
|
if (content?.length > 0) {
|
package/src/cli/init/index.js
CHANGED
|
@@ -38,6 +38,11 @@ export function init(args) {
|
|
|
38
38
|
'utf8'
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
+
// Drop `content` in the oxide engine to promote auto content
|
|
42
|
+
if (__OXIDE__) {
|
|
43
|
+
stubContentsFile = stubContentsFile.replace(/\s*content: \[\],\n/, '')
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
// Change colors import
|
|
42
47
|
stubContentsFile = stubContentsFile.replace('../colors', 'tailwindcss/colors')
|
|
43
48
|
|
package/src/css/preflight.css
CHANGED
|
@@ -163,6 +163,8 @@ optgroup,
|
|
|
163
163
|
select,
|
|
164
164
|
textarea {
|
|
165
165
|
font-family: inherit; /* 1 */
|
|
166
|
+
font-feature-settings: inherit; /* 1 */
|
|
167
|
+
font-variation-settings: inherit; /* 1 */
|
|
166
168
|
font-size: 100%; /* 1 */
|
|
167
169
|
font-weight: inherit; /* 1 */
|
|
168
170
|
line-height: inherit; /* 1 */
|
|
@@ -264,7 +266,7 @@ summary {
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
/*
|
|
267
|
-
Removes the default spacing
|
|
269
|
+
Removes the default spacing for appropriate elements.
|
|
268
270
|
*/
|
|
269
271
|
|
|
270
272
|
blockquote,
|
|
@@ -300,6 +302,10 @@ menu {
|
|
|
300
302
|
padding: 0;
|
|
301
303
|
}
|
|
302
304
|
|
|
305
|
+
dialog {
|
|
306
|
+
padding: 0;
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
/*
|
|
304
310
|
Prevent resizing textareas horizontally by default.
|
|
305
311
|
*/
|
package/src/lib/content.js
CHANGED
|
@@ -11,6 +11,28 @@ import { env } from './sharedState'
|
|
|
11
11
|
/** @typedef {import('../../types/config.js').RawFile} RawFile */
|
|
12
12
|
/** @typedef {import('../../types/config.js').FilePath} FilePath */
|
|
13
13
|
|
|
14
|
+
/*
|
|
15
|
+
* @param {import('tailwindcss').Config} tailwindConfig
|
|
16
|
+
* @param {{skip:string[]}} options
|
|
17
|
+
* @returns {ContentPath[]}
|
|
18
|
+
*/
|
|
19
|
+
function resolveContentFiles(tailwindConfig, { skip = [] } = {}) {
|
|
20
|
+
if (tailwindConfig.content.files === 'auto' && __OXIDE__) {
|
|
21
|
+
env.DEBUG && console.time('Calculating resolve content paths')
|
|
22
|
+
tailwindConfig.content.files = require('@tailwindcss/oxide').resolveContentPaths({
|
|
23
|
+
base: process.cwd(),
|
|
24
|
+
})
|
|
25
|
+
if (skip.length > 0) {
|
|
26
|
+
tailwindConfig.content.files = tailwindConfig.content.files.filter(
|
|
27
|
+
(filePath) => !skip.includes(filePath)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
env.DEBUG && console.timeEnd('Calculating resolve content paths')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return tailwindConfig.content.files
|
|
34
|
+
}
|
|
35
|
+
|
|
14
36
|
/**
|
|
15
37
|
* @typedef {object} ContentPath
|
|
16
38
|
* @property {string} original
|
|
@@ -32,7 +54,9 @@ import { env } from './sharedState'
|
|
|
32
54
|
* @returns {ContentPath[]}
|
|
33
55
|
*/
|
|
34
56
|
export function parseCandidateFiles(context, tailwindConfig) {
|
|
35
|
-
let files = tailwindConfig
|
|
57
|
+
let files = resolveContentFiles(tailwindConfig, {
|
|
58
|
+
skip: [context.userConfigPath],
|
|
59
|
+
})
|
|
36
60
|
|
|
37
61
|
// Normalize the file globs
|
|
38
62
|
files = files.filter((filePath) => typeof filePath === 'string')
|
|
@@ -167,9 +191,12 @@ function resolvePathSymlinks(contentPath) {
|
|
|
167
191
|
* @returns {[{ content: string, extension: string }[], Map<string, number>]}
|
|
168
192
|
*/
|
|
169
193
|
export function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
170
|
-
let changedContent =
|
|
171
|
-
.
|
|
172
|
-
|
|
194
|
+
let changedContent =
|
|
195
|
+
context.tailwindConfig.content.files === 'auto' && __OXIDE__
|
|
196
|
+
? []
|
|
197
|
+
: context.tailwindConfig.content.files
|
|
198
|
+
.filter((item) => typeof item.raw === 'string')
|
|
199
|
+
.map(({ raw, extension = 'html' }) => ({ content: raw, extension }))
|
|
173
200
|
|
|
174
201
|
let [changedFiles, mTimesToCommit] = resolveChangedFiles(candidateFiles, fileModifiedMap)
|
|
175
202
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dlv from 'dlv'
|
|
2
2
|
import didYouMean from 'didyoumean'
|
|
3
3
|
import transformThemeValue from '../util/transformThemeValue'
|
|
4
|
-
import parseValue from '
|
|
4
|
+
import parseValue from '../value-parser/index'
|
|
5
5
|
import { normalizeScreens } from '../util/normalizeScreens'
|
|
6
6
|
import buildMediaQuery from '../util/buildMediaQuery'
|
|
7
7
|
import { toPath } from '../util/toPath'
|
|
@@ -146,6 +146,9 @@ function resolveVNode(node, vNode, functions) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
function resolveFunctions(node, input, functions) {
|
|
149
|
+
let hasAnyFn = Object.keys(functions).some((fn) => input.includes(`${fn}(`))
|
|
150
|
+
if (!hasAnyFn) return input
|
|
151
|
+
|
|
149
152
|
return parseValue(input)
|
|
150
153
|
.walk((vNode) => {
|
|
151
154
|
resolveVNode(node, vNode, functions)
|
|
@@ -18,6 +18,7 @@ import log from '../../../util/log'
|
|
|
18
18
|
import { loadConfig } from '../../../lib/load-config'
|
|
19
19
|
import getModuleDependencies from '../../../lib/getModuleDependencies'
|
|
20
20
|
import type { Config } from '../../../../types'
|
|
21
|
+
import { validateConfig } from '../../../util/validateConfig'
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
@@ -160,7 +161,13 @@ let state = {
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
// @ts-ignore
|
|
163
|
-
|
|
164
|
+
if (__OXIDE__) {
|
|
165
|
+
this.configBag.config = validateConfig(resolveConfig(this.configBag.config))
|
|
166
|
+
} else {
|
|
167
|
+
this.configBag.config = validateConfig(
|
|
168
|
+
resolveConfig(this.configBag.config, { content: { files: [] } })
|
|
169
|
+
)
|
|
170
|
+
}
|
|
164
171
|
|
|
165
172
|
// Override content files if `--content` has been passed explicitly
|
|
166
173
|
if (content?.length > 0) {
|
|
@@ -36,6 +36,11 @@ export function init(args) {
|
|
|
36
36
|
'utf8'
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
+
// Drop `content` in the oxide engine to promote auto content
|
|
40
|
+
if (__OXIDE__) {
|
|
41
|
+
stubContentsFile = stubContentsFile.replace(/\s*content: \[\],\n/, '')
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
// Change colors import
|
|
40
45
|
stubContentsFile = stubContentsFile.replace('../colors', 'tailwindcss/colors')
|
|
41
46
|
|
package/src/util/dataTypes.js
CHANGED
|
@@ -49,10 +49,22 @@ export function normalize(value, isRoot = true) {
|
|
|
49
49
|
value = value.trim()
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
value = normalizeMathOperatorSpacing(value)
|
|
53
|
+
|
|
54
|
+
return value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Add spaces around operators inside math functions
|
|
59
|
+
* like calc() that do not follow an operator or '('.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} value
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
function normalizeMathOperatorSpacing(value) {
|
|
65
|
+
return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
|
|
55
66
|
let vars = []
|
|
67
|
+
|
|
56
68
|
return match
|
|
57
69
|
.replace(/var\((--.+?)[,)]/g, (match, g1) => {
|
|
58
70
|
vars.push(g1)
|
|
@@ -61,8 +73,6 @@ export function normalize(value, isRoot = true) {
|
|
|
61
73
|
.replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ')
|
|
62
74
|
.replace(placeholderRe, () => vars.shift())
|
|
63
75
|
})
|
|
64
|
-
|
|
65
|
-
return value
|
|
66
76
|
}
|
|
67
77
|
|
|
68
78
|
export function url(value) {
|
|
@@ -178,11 +188,12 @@ export function image(value) {
|
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
let gradientTypes = new Set([
|
|
191
|
+
'conic-gradient',
|
|
181
192
|
'linear-gradient',
|
|
182
193
|
'radial-gradient',
|
|
194
|
+
'repeating-conic-gradient',
|
|
183
195
|
'repeating-linear-gradient',
|
|
184
196
|
'repeating-radial-gradient',
|
|
185
|
-
'conic-gradient',
|
|
186
197
|
])
|
|
187
198
|
export function gradient(value) {
|
|
188
199
|
value = normalize(value)
|
|
@@ -2,7 +2,14 @@ import defaultFullConfig from '../../stubs/config.full.js'
|
|
|
2
2
|
import { flagEnabled } from '../featureFlags'
|
|
3
3
|
|
|
4
4
|
export default function getAllConfigs(config) {
|
|
5
|
-
const configs = (
|
|
5
|
+
const configs = (
|
|
6
|
+
config?.presets ?? [
|
|
7
|
+
__OXIDE__
|
|
8
|
+
? // Drop `content` in the oxide engine to promote auto content
|
|
9
|
+
Object.assign({}, defaultFullConfig, { content: 'auto' })
|
|
10
|
+
: defaultFullConfig,
|
|
11
|
+
]
|
|
12
|
+
)
|
|
6
13
|
.slice()
|
|
7
14
|
.reverse()
|
|
8
15
|
.flatMap((preset) => getAllConfigs(preset instanceof Function ? preset() : preset))
|
|
@@ -18,6 +18,10 @@ export function normalizeConfig(config) {
|
|
|
18
18
|
* }
|
|
19
19
|
*/
|
|
20
20
|
let valid = (() => {
|
|
21
|
+
if (config.content === 'auto') {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
// `config.purge` should not exist anymore
|
|
22
26
|
if (config.purge) {
|
|
23
27
|
return false
|
|
@@ -181,6 +185,31 @@ export function normalizeConfig(config) {
|
|
|
181
185
|
config.prefix = config.prefix ?? ''
|
|
182
186
|
}
|
|
183
187
|
|
|
188
|
+
let auto = (() => {
|
|
189
|
+
// Config still has a `purge` option (for backwards compatibility), auto content should not be
|
|
190
|
+
// used
|
|
191
|
+
if (config.purge) return false
|
|
192
|
+
|
|
193
|
+
//
|
|
194
|
+
if (config.content === 'auto') return true
|
|
195
|
+
|
|
196
|
+
// We don't have content at all, auto content should be used
|
|
197
|
+
if (config.content === undefined) return true
|
|
198
|
+
|
|
199
|
+
// We do have content as an object, but we don't have any files defined, auto content should
|
|
200
|
+
// be used
|
|
201
|
+
if (
|
|
202
|
+
typeof config.content === 'object' &&
|
|
203
|
+
config.content !== null &&
|
|
204
|
+
!Array.isArray(config.content)
|
|
205
|
+
) {
|
|
206
|
+
return config.content.files === undefined
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// We do have content defined, auto content should not be used
|
|
210
|
+
return false
|
|
211
|
+
})()
|
|
212
|
+
|
|
184
213
|
// Normalize the `content`
|
|
185
214
|
config.content = {
|
|
186
215
|
relative: (() => {
|
|
@@ -193,17 +222,20 @@ export function normalizeConfig(config) {
|
|
|
193
222
|
return flagEnabled(config, 'relativeContentPathsByDefault')
|
|
194
223
|
})(),
|
|
195
224
|
|
|
196
|
-
files:
|
|
197
|
-
|
|
225
|
+
files: auto
|
|
226
|
+
? 'auto'
|
|
227
|
+
: (() => {
|
|
228
|
+
let { content, purge } = config
|
|
198
229
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
230
|
+
if (content === undefined && purge === undefined) return []
|
|
231
|
+
if (Array.isArray(purge)) return purge
|
|
232
|
+
if (Array.isArray(purge?.content)) return purge.content
|
|
233
|
+
if (Array.isArray(content)) return content
|
|
234
|
+
if (Array.isArray(content?.content)) return content.content
|
|
235
|
+
if (Array.isArray(content?.files)) return content.files
|
|
204
236
|
|
|
205
|
-
|
|
206
|
-
|
|
237
|
+
return []
|
|
238
|
+
})(),
|
|
207
239
|
|
|
208
240
|
extract: (() => {
|
|
209
241
|
let extract = (() => {
|
|
@@ -286,14 +318,16 @@ export function normalizeConfig(config) {
|
|
|
286
318
|
|
|
287
319
|
// Validate globs to prevent bogus globs.
|
|
288
320
|
// E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
321
|
+
if (config.content.files !== 'auto') {
|
|
322
|
+
for (let file of config.content.files) {
|
|
323
|
+
if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
|
|
324
|
+
log.warn('invalid-glob-braces', [
|
|
325
|
+
`The glob pattern ${dim(file)} in your Tailwind CSS configuration is invalid.`,
|
|
326
|
+
`Update it to ${dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`,
|
|
327
|
+
// TODO: Add https://tw.wtf/invalid-glob-braces
|
|
328
|
+
])
|
|
329
|
+
break
|
|
330
|
+
}
|
|
297
331
|
}
|
|
298
332
|
}
|
|
299
333
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import log from './log'
|
|
2
2
|
|
|
3
3
|
export function validateConfig(config) {
|
|
4
|
-
if (config.content.files.length === 0) {
|
|
4
|
+
if (config.content.files !== 'auto' && config.content.files.length === 0) {
|
|
5
5
|
log.warn('content-problems', [
|
|
6
6
|
'The `content` option in your Tailwind CSS configuration is missing or empty.',
|
|
7
7
|
'Configure your content sources or your generated CSS will be missing styles.',
|
|
@@ -9,6 +9,13 @@ export function validateConfig(config) {
|
|
|
9
9
|
])
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
if (config.content.files === 'auto') {
|
|
13
|
+
log.warn('auto-content-experimental', [
|
|
14
|
+
'Automatic content detection in Tailwind CSS is currently in experimental preview.',
|
|
15
|
+
'Preview features are not covered by semver, and may change at any time.',
|
|
16
|
+
])
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
// Warn if the line-clamp plugin is installed
|
|
13
20
|
try {
|
|
14
21
|
let plugin = require('@tailwindcss/line-clamp')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) Bogdan Chadkin <trysound@yandex.ru>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|