tailwindcss 0.0.0-oxide-insiders.0ddc71e → 0.0.0-oxide-insiders.a7f7b76
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/lib/content.js +23 -2
- package/lib/oxide/cli/build/plugin.js +10 -5
- package/lib/oxide/cli/init/index.js +4 -0
- package/lib/util/getAllConfigs.js +3 -1
- package/lib/util/normalizeConfig.js +30 -8
- package/lib/util/validateConfig.js +7 -1
- package/package.json +2 -2
- package/src/cli/build/plugin.js +8 -1
- package/src/cli/init/index.js +5 -0
- package/src/lib/content.js +31 -4
- package/src/oxide/cli/build/plugin.ts +8 -1
- package/src/oxide/cli/init/index.ts +5 -0
- package/src/util/getAllConfigs.js +8 -1
- package/src/util/normalizeConfig.js +51 -17
- package/src/util/validateConfig.js +8 -1
package/index.css
ADDED
package/lib/cli/build/plugin.js
CHANGED
|
@@ -29,6 +29,7 @@ const _findAtConfigPath = require("../../lib/findAtConfigPath.js");
|
|
|
29
29
|
const _log = /*#__PURE__*/ _interop_require_default(require("../../util/log"));
|
|
30
30
|
const _loadconfig = require("../../lib/load-config");
|
|
31
31
|
const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("../../lib/getModuleDependencies"));
|
|
32
|
+
const _validateConfig = require("../../util/validateConfig");
|
|
32
33
|
function _interop_require_default(obj) {
|
|
33
34
|
return obj && obj.__esModule ? obj : {
|
|
34
35
|
default: obj
|
|
@@ -144,11 +145,15 @@ let state = {
|
|
|
144
145
|
}
|
|
145
146
|
};
|
|
146
147
|
// @ts-ignore
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
if (true) {
|
|
149
|
+
this.configBag.config = (0, _validateConfig.validateConfig)((0, _resolveConfig.default)(this.configBag.config));
|
|
150
|
+
} else {
|
|
151
|
+
this.configBag.config = (0, _validateConfig.validateConfig)((0, _resolveConfig.default)(this.configBag.config, {
|
|
152
|
+
content: {
|
|
153
|
+
files: []
|
|
154
|
+
}
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
152
157
|
// Override content files if `--content` has been passed explicitly
|
|
153
158
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
154
159
|
this.configBag.config.content.files = content;
|
package/lib/cli/init/index.js
CHANGED
|
@@ -37,6 +37,10 @@ function init(args) {
|
|
|
37
37
|
} else {
|
|
38
38
|
let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../stubs/config.simple.js"), "utf8");
|
|
39
39
|
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../stubs/tailwind.config.${syntax}`), "utf8");
|
|
40
|
+
// Drop `content` in the oxide engine to promote auto content
|
|
41
|
+
if (true) {
|
|
42
|
+
stubContentsFile = stubContentsFile.replace(/\s*content: \[\],\n/, "");
|
|
43
|
+
}
|
|
40
44
|
// Change colors import
|
|
41
45
|
stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
|
|
42
46
|
// Replace contents of {ts,js,cjs} file with the stub {simple,full}.
|
package/lib/lib/content.js
CHANGED
|
@@ -29,8 +29,29 @@ function _interop_require_default(obj) {
|
|
|
29
29
|
default: obj
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
/** @typedef {import('../../types/config.js').RawFile} RawFile */ /** @typedef {import('../../types/config.js').FilePath} FilePath */ /*
|
|
33
|
+
* @param {import('tailwindcss').Config} tailwindConfig
|
|
34
|
+
* @param {{skip:string[]}} options
|
|
35
|
+
* @returns {ContentPath[]}
|
|
36
|
+
*/ function resolveContentFiles(tailwindConfig, { skip =[] } = {}) {
|
|
37
|
+
if (tailwindConfig.content.files === "auto" && true) {
|
|
38
|
+
_sharedState.env.DEBUG && console.time("Calculating resolve content paths");
|
|
39
|
+
tailwindConfig.content.files = require("@tailwindcss/oxide").resolveContentPaths({
|
|
40
|
+
base: process.cwd()
|
|
41
|
+
});
|
|
42
|
+
if (skip.length > 0) {
|
|
43
|
+
tailwindConfig.content.files = tailwindConfig.content.files.filter((filePath)=>!skip.includes(filePath));
|
|
44
|
+
}
|
|
45
|
+
_sharedState.env.DEBUG && console.timeEnd("Calculating resolve content paths");
|
|
46
|
+
}
|
|
47
|
+
return tailwindConfig.content.files;
|
|
48
|
+
}
|
|
32
49
|
function parseCandidateFiles(context, tailwindConfig) {
|
|
33
|
-
let files = tailwindConfig
|
|
50
|
+
let files = resolveContentFiles(tailwindConfig, {
|
|
51
|
+
skip: [
|
|
52
|
+
context.userConfigPath
|
|
53
|
+
]
|
|
54
|
+
});
|
|
34
55
|
// Normalize the file globs
|
|
35
56
|
files = files.filter((filePath)=>typeof filePath === "string");
|
|
36
57
|
files = files.map(_normalizepath.default);
|
|
@@ -135,7 +156,7 @@ function parseCandidateFiles(context, tailwindConfig) {
|
|
|
135
156
|
return paths;
|
|
136
157
|
}
|
|
137
158
|
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
138
|
-
let changedContent = context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
|
|
159
|
+
let changedContent = context.tailwindConfig.content.files === "auto" && true ? [] : context.tailwindConfig.content.files.filter((item)=>typeof item.raw === "string").map(({ raw , extension ="html" })=>({
|
|
139
160
|
content: raw,
|
|
140
161
|
extension
|
|
141
162
|
}));
|
|
@@ -28,6 +28,7 @@ const _findAtConfigPath = require("../../../lib/findAtConfigPath");
|
|
|
28
28
|
const _log = /*#__PURE__*/ _interop_require_default(require("../../../util/log"));
|
|
29
29
|
const _loadconfig = require("../../../lib/load-config");
|
|
30
30
|
const _getModuleDependencies = /*#__PURE__*/ _interop_require_default(require("../../../lib/getModuleDependencies"));
|
|
31
|
+
const _validateConfig = require("../../../util/validateConfig");
|
|
31
32
|
function _interop_require_default(obj) {
|
|
32
33
|
return obj && obj.__esModule ? obj : {
|
|
33
34
|
default: obj
|
|
@@ -143,11 +144,15 @@ let state = {
|
|
|
143
144
|
}
|
|
144
145
|
};
|
|
145
146
|
// @ts-ignore
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
if (true) {
|
|
148
|
+
this.configBag.config = (0, _validateConfig.validateConfig)((0, _resolveConfig.default)(this.configBag.config));
|
|
149
|
+
} else {
|
|
150
|
+
this.configBag.config = (0, _validateConfig.validateConfig)((0, _resolveConfig.default)(this.configBag.config, {
|
|
151
|
+
content: {
|
|
152
|
+
files: []
|
|
153
|
+
}
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
151
156
|
// Override content files if `--content` has been passed explicitly
|
|
152
157
|
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
153
158
|
this.configBag.config.content.files = content;
|
|
@@ -36,6 +36,10 @@ function init(args) {
|
|
|
36
36
|
} else {
|
|
37
37
|
let stubContentsFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../../../../stubs/config.full.js") : _path.default.resolve(__dirname, "../../../../stubs/config.simple.js"), "utf8");
|
|
38
38
|
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, `../../../../stubs/tailwind.config.${syntax}`), "utf8");
|
|
39
|
+
// Drop `content` in the oxide engine to promote auto content
|
|
40
|
+
if (true) {
|
|
41
|
+
stubContentsFile = stubContentsFile.replace(/\s*content: \[\],\n/, "");
|
|
42
|
+
}
|
|
39
43
|
// Change colors import
|
|
40
44
|
stubContentsFile = stubContentsFile.replace("../colors", "tailwindcss/colors");
|
|
41
45
|
// Replace contents of {ts,js,cjs} file with the stub {simple,full}.
|
|
@@ -18,7 +18,9 @@ function _interop_require_default(obj) {
|
|
|
18
18
|
function getAllConfigs(config) {
|
|
19
19
|
var _config_presets;
|
|
20
20
|
const configs = ((_config_presets = config === null || config === void 0 ? void 0 : config.presets) !== null && _config_presets !== void 0 ? _config_presets : [
|
|
21
|
-
_configfull.default
|
|
21
|
+
true ? Object.assign({}, _configfull.default, {
|
|
22
|
+
content: "auto"
|
|
23
|
+
}) : _configfull.default
|
|
22
24
|
]).slice().reverse().flatMap((preset)=>getAllConfigs(preset instanceof Function ? preset() : preset));
|
|
23
25
|
const features = {
|
|
24
26
|
// Add experimental configs here...
|
|
@@ -65,6 +65,9 @@ function normalizeConfig(config) {
|
|
|
65
65
|
* transform?: TransformerFn | { [extension: string]: TransformerFn }
|
|
66
66
|
* }
|
|
67
67
|
*/ let valid = (()=>{
|
|
68
|
+
if (config.content === "auto") {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
68
71
|
// `config.purge` should not exist anymore
|
|
69
72
|
if (config.purge) {
|
|
70
73
|
return false;
|
|
@@ -191,6 +194,22 @@ function normalizeConfig(config) {
|
|
|
191
194
|
var _config_prefix;
|
|
192
195
|
config.prefix = (_config_prefix = config.prefix) !== null && _config_prefix !== void 0 ? _config_prefix : "";
|
|
193
196
|
}
|
|
197
|
+
let auto = (()=>{
|
|
198
|
+
// Config still has a `purge` option (for backwards compatibility), auto content should not be
|
|
199
|
+
// used
|
|
200
|
+
if (config.purge) return false;
|
|
201
|
+
//
|
|
202
|
+
if (config.content === "auto") return true;
|
|
203
|
+
// We don't have content at all, auto content should be used
|
|
204
|
+
if (config.content === undefined) return true;
|
|
205
|
+
// We do have content as an object, but we don't have any files defined, auto content should
|
|
206
|
+
// be used
|
|
207
|
+
if (typeof config.content === "object" && config.content !== null && !Array.isArray(config.content)) {
|
|
208
|
+
return config.content.files === undefined;
|
|
209
|
+
}
|
|
210
|
+
// We do have content defined, auto content should not be used
|
|
211
|
+
return false;
|
|
212
|
+
})();
|
|
194
213
|
// Normalize the `content`
|
|
195
214
|
config.content = {
|
|
196
215
|
relative: (()=>{
|
|
@@ -200,8 +219,9 @@ function normalizeConfig(config) {
|
|
|
200
219
|
}
|
|
201
220
|
return (0, _featureFlags.flagEnabled)(config, "relativeContentPathsByDefault");
|
|
202
221
|
})(),
|
|
203
|
-
files: (()=>{
|
|
222
|
+
files: auto ? "auto" : (()=>{
|
|
204
223
|
let { content , purge } = config;
|
|
224
|
+
if (content === undefined && purge === undefined) return [];
|
|
205
225
|
if (Array.isArray(purge)) return purge;
|
|
206
226
|
if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
|
|
207
227
|
if (Array.isArray(content)) return content;
|
|
@@ -269,13 +289,15 @@ function normalizeConfig(config) {
|
|
|
269
289
|
};
|
|
270
290
|
// Validate globs to prevent bogus globs.
|
|
271
291
|
// E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
292
|
+
if (config.content.files !== "auto") {
|
|
293
|
+
for (let file of config.content.files){
|
|
294
|
+
if (typeof file === "string" && /{([^,]*?)}/g.test(file)) {
|
|
295
|
+
_log.default.warn("invalid-glob-braces", [
|
|
296
|
+
`The glob pattern ${(0, _log.dim)(file)} in your Tailwind CSS configuration is invalid.`,
|
|
297
|
+
`Update it to ${(0, _log.dim)(file.replace(/{([^,]*?)}/g, "$1"))} to silence this warning.`
|
|
298
|
+
]);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
279
301
|
}
|
|
280
302
|
}
|
|
281
303
|
return config;
|
|
@@ -15,13 +15,19 @@ function _interop_require_default(obj) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function validateConfig(config) {
|
|
18
|
-
if (config.content.files.length === 0) {
|
|
18
|
+
if (config.content.files !== "auto" && config.content.files.length === 0) {
|
|
19
19
|
_log.default.warn("content-problems", [
|
|
20
20
|
"The `content` option in your Tailwind CSS configuration is missing or empty.",
|
|
21
21
|
"Configure your content sources or your generated CSS will be missing styles.",
|
|
22
22
|
"https://tailwindcss.com/docs/content-configuration"
|
|
23
23
|
]);
|
|
24
24
|
}
|
|
25
|
+
if (config.content.files === "auto") {
|
|
26
|
+
_log.default.warn("auto-content-experimental", [
|
|
27
|
+
"Automatic content detection in Tailwind CSS is currently in experimental preview.",
|
|
28
|
+
"Preview features are not covered by semver, and may change at any time."
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
25
31
|
// Warn if the line-clamp plugin is installed
|
|
26
32
|
try {
|
|
27
33
|
let plugin = require("@tailwindcss/line-clamp");
|
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.a7f7b76",
|
|
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.a7f7b76",
|
|
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/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
|
|
|
@@ -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
|
|
|
@@ -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')
|