tailwindcss 3.0.22 → 3.1.0
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 +92 -2
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +10 -5
- package/lib/cli.js +266 -203
- package/lib/constants.js +8 -8
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +1662 -1554
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +14 -12
- package/lib/index.js +16 -6
- package/lib/lib/cacheInvalidation.js +87 -0
- package/lib/lib/collapseAdjacentRules.js +30 -15
- package/lib/lib/collapseDuplicateDeclarations.js +1 -1
- package/lib/lib/defaultExtractor.js +191 -30
- package/lib/lib/detectNesting.js +9 -9
- package/lib/lib/evaluateTailwindFunctions.js +37 -28
- package/lib/lib/expandApplyAtRules.js +379 -189
- package/lib/lib/expandTailwindAtRules.js +168 -144
- package/lib/lib/generateRules.js +190 -81
- package/lib/lib/getModuleDependencies.js +14 -14
- package/lib/lib/normalizeTailwindDirectives.js +35 -35
- package/lib/lib/partitionApplyAtRules.js +7 -7
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +80 -79
- package/lib/lib/setupContextUtils.js +207 -170
- package/lib/lib/setupTrackingContext.js +61 -63
- package/lib/lib/sharedState.js +11 -8
- package/lib/lib/substituteScreenAtRules.js +3 -4
- package/lib/postcss-plugins/nesting/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +1 -1
- package/lib/postcss-plugins/nesting/plugin.js +40 -9
- package/lib/processTailwindFeatures.js +7 -7
- package/lib/public/colors.js +241 -241
- package/lib/public/resolve-config.js +5 -5
- package/lib/util/buildMediaQuery.js +2 -3
- package/lib/util/cloneDeep.js +3 -5
- package/lib/util/cloneNodes.js +12 -1
- package/lib/util/color.js +42 -51
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +6 -7
- package/lib/util/dataTypes.js +85 -81
- package/lib/util/escapeClassName.js +5 -5
- package/lib/util/escapeCommas.js +1 -1
- package/lib/util/flattenColorPalette.js +4 -7
- package/lib/util/formatVariantSelector.js +82 -75
- package/lib/util/getAllConfigs.js +15 -10
- package/lib/util/hashConfig.js +5 -5
- package/lib/util/isKeyframeRule.js +1 -1
- package/lib/util/isPlainObject.js +1 -1
- package/lib/util/isValidArbitraryValue.js +26 -27
- package/lib/util/log.js +9 -10
- package/lib/util/nameClass.js +7 -7
- package/lib/util/negateValue.js +4 -5
- package/lib/util/normalizeConfig.js +68 -58
- package/lib/util/normalizeScreens.js +5 -6
- package/lib/util/parseAnimationValue.js +56 -57
- package/lib/util/parseBoxShadowValue.js +19 -20
- package/lib/util/parseDependency.js +32 -32
- package/lib/util/parseObjectStyles.js +6 -6
- package/lib/util/pluginUtils.js +20 -12
- package/lib/util/prefixSelector.js +1 -1
- package/lib/util/resolveConfig.js +81 -58
- package/lib/util/resolveConfigPath.js +16 -16
- package/lib/util/responsive.js +6 -6
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/toColorValue.js +1 -1
- package/lib/util/toPath.js +2 -2
- package/lib/util/transformThemeValue.js +30 -28
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +23 -23
- package/package.json +33 -27
- package/peers/index.js +7728 -5848
- package/plugin.d.ts +11 -0
- package/scripts/generate-types.js +52 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +118 -24
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +142 -30
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +4 -4
- package/src/index.js +15 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/defaultExtractor.js +177 -33
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +418 -186
- package/src/lib/expandTailwindAtRules.js +30 -10
- package/src/lib/generateRules.js +142 -51
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +7 -3
- package/src/lib/setupContextUtils.js +142 -87
- package/src/lib/setupTrackingContext.js +7 -3
- package/src/lib/sharedState.js +2 -0
- package/src/postcss-plugins/nesting/README.md +2 -2
- package/src/postcss-plugins/nesting/plugin.js +36 -0
- package/src/util/cloneNodes.js +14 -1
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +14 -6
- package/src/util/formatVariantSelector.js +79 -62
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +8 -8
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -2
- package/src/util/pluginUtils.js +13 -1
- package/src/util/resolveConfig.js +66 -22
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +5 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +325 -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/index.d.ts +1 -0
|
@@ -10,44 +10,189 @@ var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
|
10
10
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
11
11
|
var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
|
|
12
12
|
var _defaultExtractor = require("./defaultExtractor");
|
|
13
|
+
function expandTailwindAtRules(context) {
|
|
14
|
+
return (root)=>{
|
|
15
|
+
let layerNodes = {
|
|
16
|
+
base: null,
|
|
17
|
+
components: null,
|
|
18
|
+
utilities: null,
|
|
19
|
+
variants: null
|
|
20
|
+
};
|
|
21
|
+
root.walkAtRules((rule)=>{
|
|
22
|
+
// Make sure this file contains Tailwind directives. If not, we can save
|
|
23
|
+
// a lot of work and bail early. Also we don't have to register our touch
|
|
24
|
+
// file as a dependency since the output of this CSS does not depend on
|
|
25
|
+
// the source of any templates. Think Vue <style> blocks for example.
|
|
26
|
+
if (rule.name === "tailwind") {
|
|
27
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
28
|
+
layerNodes[rule.params] = rule;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
33
|
+
return root;
|
|
34
|
+
}
|
|
35
|
+
// ---
|
|
36
|
+
// Find potential rules in changed files
|
|
37
|
+
let candidates = new Set([
|
|
38
|
+
sharedState.NOT_ON_DEMAND
|
|
39
|
+
]);
|
|
40
|
+
let seen = new Set();
|
|
41
|
+
env.DEBUG && console.time("Reading changed files");
|
|
42
|
+
for (let { content , extension } of context.changedContent){
|
|
43
|
+
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
44
|
+
let extractor = getExtractor(context, extension);
|
|
45
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
46
|
+
}
|
|
47
|
+
env.DEBUG && console.timeEnd("Reading changed files");
|
|
48
|
+
// ---
|
|
49
|
+
// Generate the actual CSS
|
|
50
|
+
let classCacheCount = context.classCache.size;
|
|
51
|
+
env.DEBUG && console.time("Generate rules");
|
|
52
|
+
let rules = (0, _generateRules).generateRules(candidates, context);
|
|
53
|
+
env.DEBUG && console.timeEnd("Generate rules");
|
|
54
|
+
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
55
|
+
env.DEBUG && console.time("Build stylesheet");
|
|
56
|
+
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
57
|
+
for (let rule of rules){
|
|
58
|
+
context.ruleCache.add(rule);
|
|
59
|
+
}
|
|
60
|
+
context.stylesheetCache = buildStylesheet([
|
|
61
|
+
...context.ruleCache
|
|
62
|
+
], context);
|
|
63
|
+
}
|
|
64
|
+
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
65
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
66
|
+
// ---
|
|
67
|
+
// Replace any Tailwind directives with generated CSS
|
|
68
|
+
if (layerNodes.base) {
|
|
69
|
+
layerNodes.base.before((0, _cloneNodes).default([
|
|
70
|
+
...baseNodes,
|
|
71
|
+
...defaultNodes
|
|
72
|
+
], layerNodes.base.source, {
|
|
73
|
+
layer: "base"
|
|
74
|
+
}));
|
|
75
|
+
layerNodes.base.remove();
|
|
76
|
+
}
|
|
77
|
+
if (layerNodes.components) {
|
|
78
|
+
layerNodes.components.before((0, _cloneNodes).default([
|
|
79
|
+
...componentNodes
|
|
80
|
+
], layerNodes.components.source, {
|
|
81
|
+
layer: "components"
|
|
82
|
+
}));
|
|
83
|
+
layerNodes.components.remove();
|
|
84
|
+
}
|
|
85
|
+
if (layerNodes.utilities) {
|
|
86
|
+
layerNodes.utilities.before((0, _cloneNodes).default([
|
|
87
|
+
...utilityNodes
|
|
88
|
+
], layerNodes.utilities.source, {
|
|
89
|
+
layer: "utilities"
|
|
90
|
+
}));
|
|
91
|
+
layerNodes.utilities.remove();
|
|
92
|
+
}
|
|
93
|
+
// We do post-filtering to not alter the emitted order of the variants
|
|
94
|
+
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
95
|
+
var ref;
|
|
96
|
+
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
97
|
+
if (parentLayer === "components") {
|
|
98
|
+
return layerNodes.components !== null;
|
|
99
|
+
}
|
|
100
|
+
if (parentLayer === "utilities") {
|
|
101
|
+
return layerNodes.utilities !== null;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
if (layerNodes.variants) {
|
|
106
|
+
layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source, {
|
|
107
|
+
layer: "variants"
|
|
108
|
+
}));
|
|
109
|
+
layerNodes.variants.remove();
|
|
110
|
+
} else if (variantNodes.length > 0) {
|
|
111
|
+
root.append((0, _cloneNodes).default(variantNodes, root.source, {
|
|
112
|
+
layer: "variants"
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
116
|
+
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
117
|
+
var ref;
|
|
118
|
+
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === "utilities";
|
|
119
|
+
});
|
|
120
|
+
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
121
|
+
_log.default.warn("content-problems", [
|
|
122
|
+
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
123
|
+
"https://tailwindcss.com/docs/content-configuration",
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
// ---
|
|
127
|
+
if (env.DEBUG) {
|
|
128
|
+
console.log("Potential classes: ", candidates.size);
|
|
129
|
+
console.log("Active contexts: ", sharedState.contextSourcesMap.size);
|
|
130
|
+
}
|
|
131
|
+
// Clear the cache for the changed files
|
|
132
|
+
context.changedContent = [];
|
|
133
|
+
// Cleanup any leftover @layer atrules
|
|
134
|
+
root.walkAtRules("layer", (rule)=>{
|
|
135
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
136
|
+
rule.remove();
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
}
|
|
13
141
|
function _interopRequireDefault(obj) {
|
|
14
142
|
return obj && obj.__esModule ? obj : {
|
|
15
143
|
default: obj
|
|
16
144
|
};
|
|
17
145
|
}
|
|
146
|
+
function _getRequireWildcardCache() {
|
|
147
|
+
if (typeof WeakMap !== "function") return null;
|
|
148
|
+
var cache = new WeakMap();
|
|
149
|
+
_getRequireWildcardCache = function() {
|
|
150
|
+
return cache;
|
|
151
|
+
};
|
|
152
|
+
return cache;
|
|
153
|
+
}
|
|
18
154
|
function _interopRequireWildcard(obj) {
|
|
19
155
|
if (obj && obj.__esModule) {
|
|
20
156
|
return obj;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
157
|
+
}
|
|
158
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
159
|
+
return {
|
|
160
|
+
default: obj
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var cache = _getRequireWildcardCache();
|
|
164
|
+
if (cache && cache.has(obj)) {
|
|
165
|
+
return cache.get(obj);
|
|
166
|
+
}
|
|
167
|
+
var newObj = {};
|
|
168
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
169
|
+
for(var key in obj){
|
|
170
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
171
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
172
|
+
if (desc && (desc.get || desc.set)) {
|
|
173
|
+
Object.defineProperty(newObj, key, desc);
|
|
174
|
+
} else {
|
|
175
|
+
newObj[key] = obj[key];
|
|
33
176
|
}
|
|
34
177
|
}
|
|
35
|
-
newObj.default = obj;
|
|
36
|
-
return newObj;
|
|
37
178
|
}
|
|
179
|
+
newObj.default = obj;
|
|
180
|
+
if (cache) {
|
|
181
|
+
cache.set(obj, newObj);
|
|
182
|
+
}
|
|
183
|
+
return newObj;
|
|
38
184
|
}
|
|
39
185
|
let env = sharedState.env;
|
|
40
186
|
const builtInExtractors = {
|
|
41
187
|
DEFAULT: _defaultExtractor.defaultExtractor
|
|
42
188
|
};
|
|
43
189
|
const builtInTransformers = {
|
|
44
|
-
DEFAULT: (content)=>content
|
|
45
|
-
,
|
|
46
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
190
|
+
DEFAULT: (content)=>content,
|
|
191
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
47
192
|
};
|
|
48
|
-
function getExtractor(
|
|
49
|
-
let extractors = tailwindConfig.content.extract;
|
|
50
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
193
|
+
function getExtractor(context, fileExtension) {
|
|
194
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
195
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
51
196
|
}
|
|
52
197
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
53
198
|
let transformers = tailwindConfig.content.transform;
|
|
@@ -63,7 +208,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
63
208
|
maxSize: 25000
|
|
64
209
|
}));
|
|
65
210
|
}
|
|
66
|
-
for (let line of content.split(
|
|
211
|
+
for (let line of content.split("\n")){
|
|
67
212
|
line = line.trim();
|
|
68
213
|
if (seen.has(line)) {
|
|
69
214
|
continue;
|
|
@@ -74,8 +219,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
74
219
|
candidates.add(match);
|
|
75
220
|
}
|
|
76
221
|
} else {
|
|
77
|
-
let extractorMatches = extractor(line).filter((s)=>s !==
|
|
78
|
-
);
|
|
222
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
79
223
|
let lineMatchesSet = new Set(extractorMatches);
|
|
80
224
|
for (let match of lineMatchesSet){
|
|
81
225
|
candidates.add(match);
|
|
@@ -85,8 +229,7 @@ function getClassCandidates(content, extractor, candidates, seen) {
|
|
|
85
229
|
}
|
|
86
230
|
}
|
|
87
231
|
function buildStylesheet(rules, context) {
|
|
88
|
-
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
|
|
89
|
-
);
|
|
232
|
+
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z));
|
|
90
233
|
let returnValue = {
|
|
91
234
|
base: new Set(),
|
|
92
235
|
defaults: new Set(),
|
|
@@ -131,122 +274,3 @@ function buildStylesheet(rules, context) {
|
|
|
131
274
|
}
|
|
132
275
|
return returnValue;
|
|
133
276
|
}
|
|
134
|
-
function expandTailwindAtRules(context) {
|
|
135
|
-
return (root)=>{
|
|
136
|
-
let layerNodes = {
|
|
137
|
-
base: null,
|
|
138
|
-
components: null,
|
|
139
|
-
utilities: null,
|
|
140
|
-
variants: null
|
|
141
|
-
};
|
|
142
|
-
root.walkAtRules((rule)=>{
|
|
143
|
-
// Make sure this file contains Tailwind directives. If not, we can save
|
|
144
|
-
// a lot of work and bail early. Also we don't have to register our touch
|
|
145
|
-
// file as a dependency since the output of this CSS does not depend on
|
|
146
|
-
// the source of any templates. Think Vue <style> blocks for example.
|
|
147
|
-
if (rule.name === 'tailwind') {
|
|
148
|
-
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
149
|
-
layerNodes[rule.params] = rule;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
154
|
-
)) {
|
|
155
|
-
return root;
|
|
156
|
-
}
|
|
157
|
-
// ---
|
|
158
|
-
// Find potential rules in changed files
|
|
159
|
-
let candidates = new Set([
|
|
160
|
-
'*'
|
|
161
|
-
]);
|
|
162
|
-
let seen = new Set();
|
|
163
|
-
env.DEBUG && console.time('Reading changed files');
|
|
164
|
-
for (let { content , extension } of context.changedContent){
|
|
165
|
-
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
166
|
-
let extractor = getExtractor(context.tailwindConfig, extension);
|
|
167
|
-
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
168
|
-
}
|
|
169
|
-
env.DEBUG && console.timeEnd('Reading changed files');
|
|
170
|
-
// ---
|
|
171
|
-
// Generate the actual CSS
|
|
172
|
-
let classCacheCount = context.classCache.size;
|
|
173
|
-
env.DEBUG && console.time('Generate rules');
|
|
174
|
-
let rules = (0, _generateRules).generateRules(candidates, context);
|
|
175
|
-
env.DEBUG && console.timeEnd('Generate rules');
|
|
176
|
-
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
177
|
-
env.DEBUG && console.time('Build stylesheet');
|
|
178
|
-
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
179
|
-
for (let rule of rules){
|
|
180
|
-
context.ruleCache.add(rule);
|
|
181
|
-
}
|
|
182
|
-
context.stylesheetCache = buildStylesheet([
|
|
183
|
-
...context.ruleCache
|
|
184
|
-
], context);
|
|
185
|
-
}
|
|
186
|
-
env.DEBUG && console.timeEnd('Build stylesheet');
|
|
187
|
-
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
188
|
-
// ---
|
|
189
|
-
// Replace any Tailwind directives with generated CSS
|
|
190
|
-
if (layerNodes.base) {
|
|
191
|
-
layerNodes.base.before((0, _cloneNodes).default([
|
|
192
|
-
...baseNodes,
|
|
193
|
-
...defaultNodes
|
|
194
|
-
], layerNodes.base.source));
|
|
195
|
-
layerNodes.base.remove();
|
|
196
|
-
}
|
|
197
|
-
if (layerNodes.components) {
|
|
198
|
-
layerNodes.components.before((0, _cloneNodes).default([
|
|
199
|
-
...componentNodes
|
|
200
|
-
], layerNodes.components.source));
|
|
201
|
-
layerNodes.components.remove();
|
|
202
|
-
}
|
|
203
|
-
if (layerNodes.utilities) {
|
|
204
|
-
layerNodes.utilities.before((0, _cloneNodes).default([
|
|
205
|
-
...utilityNodes
|
|
206
|
-
], layerNodes.utilities.source));
|
|
207
|
-
layerNodes.utilities.remove();
|
|
208
|
-
}
|
|
209
|
-
// We do post-filtering to not alter the emitted order of the variants
|
|
210
|
-
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
211
|
-
var ref;
|
|
212
|
-
const parentLayer = (ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer;
|
|
213
|
-
if (parentLayer === 'components') {
|
|
214
|
-
return layerNodes.components !== null;
|
|
215
|
-
}
|
|
216
|
-
if (parentLayer === 'utilities') {
|
|
217
|
-
return layerNodes.utilities !== null;
|
|
218
|
-
}
|
|
219
|
-
return true;
|
|
220
|
-
});
|
|
221
|
-
if (layerNodes.variants) {
|
|
222
|
-
layerNodes.variants.before((0, _cloneNodes).default(variantNodes, layerNodes.variants.source));
|
|
223
|
-
layerNodes.variants.remove();
|
|
224
|
-
} else if (variantNodes.length > 0) {
|
|
225
|
-
root.append((0, _cloneNodes).default(variantNodes, root.source));
|
|
226
|
-
}
|
|
227
|
-
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
228
|
-
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
229
|
-
var ref;
|
|
230
|
-
return ((ref = node.raws.tailwind) === null || ref === void 0 ? void 0 : ref.parentLayer) === 'utilities';
|
|
231
|
-
});
|
|
232
|
-
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
233
|
-
_log.default.warn('content-problems', [
|
|
234
|
-
'No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.',
|
|
235
|
-
'https://tailwindcss.com/docs/content-configuration',
|
|
236
|
-
]);
|
|
237
|
-
}
|
|
238
|
-
// ---
|
|
239
|
-
if (env.DEBUG) {
|
|
240
|
-
console.log('Potential classes: ', candidates.size);
|
|
241
|
-
console.log('Active contexts: ', sharedState.contextSourcesMap.size);
|
|
242
|
-
}
|
|
243
|
-
// Clear the cache for the changed files
|
|
244
|
-
context.changedContent = [];
|
|
245
|
-
// Cleanup any leftover @layer atrules
|
|
246
|
-
root.walkAtRules('layer', (rule)=>{
|
|
247
|
-
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
248
|
-
rule.remove();
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
}
|