tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21
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 +106 -1
- package/README.md +1 -1
- package/colors.js +1 -304
- package/defaultConfig.js +1 -4
- package/defaultTheme.js +1 -4
- package/lib/cli-peer-dependencies.js +4 -9
- package/lib/cli.js +646 -705
- package/lib/constants.js +15 -15
- package/lib/corePluginList.js +174 -4
- package/lib/corePlugins.js +3637 -2934
- package/lib/css/preflight.css +14 -1
- package/lib/featureFlags.js +44 -44
- package/lib/index.js +25 -24
- package/lib/lib/collapseAdjacentRules.js +33 -35
- package/lib/lib/collapseDuplicateDeclarations.js +29 -0
- package/lib/lib/detectNesting.js +34 -0
- package/lib/lib/evaluateTailwindFunctions.js +134 -155
- package/lib/lib/expandApplyAtRules.js +183 -200
- package/lib/lib/expandTailwindAtRules.js +219 -232
- package/lib/lib/generateRules.js +478 -311
- package/lib/lib/getModuleDependencies.js +36 -41
- package/lib/lib/normalizeTailwindDirectives.js +66 -58
- package/lib/lib/resolveDefaultsAtRules.js +110 -90
- package/lib/lib/setupContextUtils.js +740 -580
- package/lib/lib/setupTrackingContext.js +142 -162
- package/lib/lib/setupWatchingContext.js +235 -278
- package/lib/lib/sharedState.js +7 -17
- package/lib/lib/substituteScreenAtRules.js +22 -26
- package/lib/processTailwindFeatures.js +38 -44
- package/lib/public/colors.js +329 -0
- package/lib/public/create-plugin.js +13 -0
- package/lib/public/default-config.js +14 -0
- package/lib/public/default-theme.js +14 -0
- package/lib/public/resolve-config.js +19 -0
- package/lib/util/bigSign.js +3 -5
- package/lib/util/buildMediaQuery.js +15 -31
- package/lib/util/cloneDeep.js +14 -13
- package/lib/util/cloneNodes.js +9 -13
- package/lib/util/color.js +69 -59
- package/lib/util/configurePlugins.js +13 -14
- package/lib/util/createPlugin.js +21 -24
- package/lib/util/createUtilityPlugin.js +47 -45
- package/lib/util/dataTypes.js +231 -0
- package/lib/util/defaults.js +10 -14
- package/lib/util/escapeClassName.js +12 -14
- package/lib/util/escapeCommas.js +3 -5
- package/lib/util/flattenColorPalette.js +14 -10
- package/lib/util/formatVariantSelector.js +186 -0
- package/lib/util/getAllConfigs.js +23 -16
- package/lib/util/hashConfig.js +10 -10
- package/lib/util/isKeyframeRule.js +3 -5
- package/lib/util/isPlainObject.js +7 -10
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/log.js +39 -30
- package/lib/util/nameClass.js +23 -23
- package/lib/util/negateValue.js +14 -15
- package/lib/util/normalizeConfig.js +208 -0
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseAnimationValue.js +82 -53
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/parseDependency.js +49 -60
- package/lib/util/parseObjectStyles.js +23 -20
- package/lib/util/pluginUtils.js +153 -285
- package/lib/util/prefixSelector.js +14 -16
- package/lib/util/resolveConfig.js +194 -249
- package/lib/util/resolveConfigPath.js +38 -45
- package/lib/util/responsive.js +12 -11
- package/lib/util/tap.js +4 -6
- package/lib/util/toColorValue.js +4 -5
- package/lib/util/toPath.js +4 -6
- package/lib/util/transformThemeValue.js +57 -26
- package/lib/util/withAlphaVariable.js +56 -54
- package/package.json +27 -37
- package/peers/index.js +73099 -84294
- package/plugin.js +1 -3
- package/resolveConfig.js +1 -7
- package/scripts/create-plugin-list.js +2 -2
- package/src/cli.js +27 -18
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2124 -1968
- package/src/css/preflight.css +14 -1
- package/src/featureFlags.js +12 -6
- package/src/lib/collapseDuplicateDeclarations.js +28 -0
- package/src/lib/detectNesting.js +39 -0
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +24 -32
- package/src/lib/generateRules.js +230 -20
- package/src/lib/normalizeTailwindDirectives.js +3 -2
- package/src/lib/resolveDefaultsAtRules.js +46 -30
- package/src/lib/setupContextUtils.js +275 -113
- package/src/lib/setupTrackingContext.js +9 -8
- package/src/lib/setupWatchingContext.js +12 -7
- package/src/lib/sharedState.js +1 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/processTailwindFeatures.js +8 -1
- package/src/public/colors.js +300 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +246 -0
- package/src/util/formatVariantSelector.js +196 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +18 -21
- package/src/util/nameClass.js +10 -6
- package/src/util/negateValue.js +4 -2
- package/src/util/normalizeConfig.js +249 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/parseDependency.js +4 -0
- package/src/util/pluginUtils.js +101 -204
- package/src/util/prefixSelector.js +1 -4
- package/src/util/resolveConfig.js +12 -65
- package/src/util/transformThemeValue.js +22 -7
- package/src/util/withAlphaVariable.js +13 -8
- package/stubs/defaultConfig.stub.js +163 -97
- package/stubs/simpleConfig.stub.js +0 -1
|
@@ -1,260 +1,247 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = expandTailwindAtRules;
|
|
7
|
-
|
|
6
|
+
var _quickLru = _interopRequireDefault(require("quick-lru"));
|
|
8
7
|
var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
9
|
-
|
|
10
8
|
var _generateRules = require("./generateRules");
|
|
11
|
-
|
|
12
9
|
var _bigSign = _interopRequireDefault(require("../util/bigSign"));
|
|
13
|
-
|
|
14
10
|
var _cloneNodes = _interopRequireDefault(require("../util/cloneNodes"));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj
|
|
21
|
-
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function _interopRequireWildcard(obj) {
|
|
17
|
+
if (obj && obj.__esModule) {
|
|
18
|
+
return obj;
|
|
19
|
+
} else {
|
|
20
|
+
var newObj = {
|
|
21
|
+
};
|
|
22
|
+
if (obj != null) {
|
|
23
|
+
for(var key in obj){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
25
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {
|
|
26
|
+
};
|
|
27
|
+
if (desc.get || desc.set) {
|
|
28
|
+
Object.defineProperty(newObj, key, desc);
|
|
29
|
+
} else {
|
|
30
|
+
newObj[key] = obj[key];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
newObj.default = obj;
|
|
36
|
+
return newObj;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
22
39
|
let env = sharedState.env;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
const PATTERNS = [
|
|
41
|
+
/([^<>"'`\s]*\[\w*'[^"`\s]*'?\])/.source,
|
|
42
|
+
/([^<>"'`\s]*\[\w*"[^"`\s]*"?\])/.source,
|
|
43
|
+
/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source,
|
|
44
|
+
/([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source,
|
|
45
|
+
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source,
|
|
46
|
+
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
47
|
+
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
48
|
+
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
49
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
50
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
51
|
+
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
52
|
+
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
28
53
|
].join('|');
|
|
29
54
|
const BROAD_MATCH_GLOBAL_REGEXP = new RegExp(PATTERNS, 'g');
|
|
30
55
|
const INNER_MATCH_GLOBAL_REGEXP = /[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g;
|
|
31
56
|
const builtInExtractors = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
DEFAULT: (content)=>{
|
|
58
|
+
let broadMatches = content.match(BROAD_MATCH_GLOBAL_REGEXP) || [];
|
|
59
|
+
let innerMatches = content.match(INNER_MATCH_GLOBAL_REGEXP) || [];
|
|
60
|
+
return [
|
|
61
|
+
...broadMatches,
|
|
62
|
+
...innerMatches
|
|
63
|
+
];
|
|
64
|
+
}
|
|
37
65
|
};
|
|
38
66
|
const builtInTransformers = {
|
|
39
|
-
|
|
40
|
-
|
|
67
|
+
DEFAULT: (content)=>content
|
|
68
|
+
,
|
|
69
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, ' ')
|
|
41
70
|
};
|
|
42
|
-
|
|
43
71
|
function getExtractor(tailwindConfig, fileExtension) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (typeof extractors === 'function') {
|
|
48
|
-
extractors = {
|
|
49
|
-
DEFAULT: extractors
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (contentOptions.defaultExtractor) {
|
|
54
|
-
extractors.DEFAULT = contentOptions.defaultExtractor;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
for (let {
|
|
58
|
-
extensions,
|
|
59
|
-
extractor
|
|
60
|
-
} of contentOptions.extractors || []) {
|
|
61
|
-
for (let extension of extensions) {
|
|
62
|
-
extractors[extension] = extractor;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
72
|
+
let extractors = tailwindConfig.content.extract;
|
|
73
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
67
74
|
}
|
|
68
|
-
|
|
69
75
|
function getTransformer(tailwindConfig, fileExtension) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
79
|
-
} // Scans template contents for possible classes. This is a hot path on initial build but
|
|
76
|
+
let transformers = tailwindConfig.content.transform;
|
|
77
|
+
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
78
|
+
}
|
|
79
|
+
let extractorCache = new WeakMap();
|
|
80
|
+
// Scans template contents for possible classes. This is a hot path on initial build but
|
|
80
81
|
// not too important for subsequent builds. The faster the better though — if we can speed
|
|
81
82
|
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (seen.has(line)) {
|
|
89
|
-
continue;
|
|
83
|
+
function getClassCandidates(content, extractor, candidates, seen) {
|
|
84
|
+
if (!extractorCache.has(extractor)) {
|
|
85
|
+
extractorCache.set(extractor, new _quickLru.default({
|
|
86
|
+
maxSize: 25000
|
|
87
|
+
}));
|
|
90
88
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
for (let line of content.split('\n')){
|
|
90
|
+
line = line.trim();
|
|
91
|
+
if (seen.has(line)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
seen.add(line);
|
|
95
|
+
if (extractorCache.get(extractor).has(line)) {
|
|
96
|
+
for (let match of extractorCache.get(extractor).get(line)){
|
|
97
|
+
candidates.add(match);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
let extractorMatches = extractor(line).filter((s)=>s !== '!*'
|
|
101
|
+
);
|
|
102
|
+
let lineMatchesSet = new Set(extractorMatches);
|
|
103
|
+
for (let match of lineMatchesSet){
|
|
104
|
+
candidates.add(match);
|
|
105
|
+
}
|
|
106
|
+
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
107
|
+
}
|
|
107
108
|
}
|
|
108
|
-
}
|
|
109
109
|
}
|
|
110
|
-
|
|
111
110
|
function buildStylesheet(rules, context) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (sort & context.layerOrder.user) {
|
|
151
|
-
returnValue.user.add(rule);
|
|
152
|
-
continue;
|
|
111
|
+
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
|
|
112
|
+
);
|
|
113
|
+
let returnValue = {
|
|
114
|
+
base: new Set(),
|
|
115
|
+
components: new Set(),
|
|
116
|
+
utilities: new Set(),
|
|
117
|
+
variants: new Set(),
|
|
118
|
+
// All the CSS that is not Tailwind related can be put in this bucket. This
|
|
119
|
+
// will make it easier to later use this information when we want to
|
|
120
|
+
// `@apply` for example. The main reason we do this here is because we
|
|
121
|
+
// still need to make sure the order is correct. Last but not least, we
|
|
122
|
+
// will make sure to always re-inject this section into the css, even if
|
|
123
|
+
// certain rules were not used. This means that it will look like a no-op
|
|
124
|
+
// from the user's perspective, but we gathered all the useful information
|
|
125
|
+
// we need.
|
|
126
|
+
user: new Set()
|
|
127
|
+
};
|
|
128
|
+
for (let [sort, rule] of sortedRules){
|
|
129
|
+
if (sort >= context.minimumScreen) {
|
|
130
|
+
returnValue.variants.add(rule);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (sort & context.layerOrder.base) {
|
|
134
|
+
returnValue.base.add(rule);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (sort & context.layerOrder.components) {
|
|
138
|
+
returnValue.components.add(rule);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (sort & context.layerOrder.utilities) {
|
|
142
|
+
returnValue.utilities.add(rule);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (sort & context.layerOrder.user) {
|
|
146
|
+
returnValue.user.add(rule);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
153
149
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return returnValue;
|
|
150
|
+
return returnValue;
|
|
157
151
|
}
|
|
158
|
-
|
|
159
152
|
function expandTailwindAtRules(context) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
256
|
-
rule.remove();
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
}
|
|
153
|
+
return (root)=>{
|
|
154
|
+
let layerNodes = {
|
|
155
|
+
base: null,
|
|
156
|
+
components: null,
|
|
157
|
+
utilities: null,
|
|
158
|
+
variants: null
|
|
159
|
+
};
|
|
160
|
+
// Make sure this file contains Tailwind directives. If not, we can save
|
|
161
|
+
// a lot of work and bail early. Also we don't have to register our touch
|
|
162
|
+
// file as a dependency since the output of this CSS does not depend on
|
|
163
|
+
// the source of any templates. Think Vue <style> blocks for example.
|
|
164
|
+
root.walkAtRules('tailwind', (rule)=>{
|
|
165
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
166
|
+
layerNodes[rule.params] = rule;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (Object.values(layerNodes).every((n)=>n === null
|
|
170
|
+
)) {
|
|
171
|
+
return root;
|
|
172
|
+
}
|
|
173
|
+
// ---
|
|
174
|
+
// Find potential rules in changed files
|
|
175
|
+
let candidates = new Set([
|
|
176
|
+
'*'
|
|
177
|
+
]);
|
|
178
|
+
let seen = new Set();
|
|
179
|
+
env.DEBUG && console.time('Reading changed files');
|
|
180
|
+
for (let { content , extension } of context.changedContent){
|
|
181
|
+
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
182
|
+
let extractor = getExtractor(context.tailwindConfig, extension);
|
|
183
|
+
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
184
|
+
}
|
|
185
|
+
// ---
|
|
186
|
+
// Generate the actual CSS
|
|
187
|
+
let classCacheCount = context.classCache.size;
|
|
188
|
+
env.DEBUG && console.time('Generate rules');
|
|
189
|
+
let rules = (0, _generateRules).generateRules(candidates, context);
|
|
190
|
+
env.DEBUG && console.timeEnd('Generate rules');
|
|
191
|
+
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
192
|
+
env.DEBUG && console.time('Build stylesheet');
|
|
193
|
+
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
194
|
+
for (let rule of rules){
|
|
195
|
+
context.ruleCache.add(rule);
|
|
196
|
+
}
|
|
197
|
+
context.stylesheetCache = buildStylesheet([
|
|
198
|
+
...context.ruleCache
|
|
199
|
+
], context);
|
|
200
|
+
}
|
|
201
|
+
env.DEBUG && console.timeEnd('Build stylesheet');
|
|
202
|
+
let { base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes , } = context.stylesheetCache;
|
|
203
|
+
// ---
|
|
204
|
+
// Replace any Tailwind directives with generated CSS
|
|
205
|
+
if (layerNodes.base) {
|
|
206
|
+
layerNodes.base.before((0, _cloneNodes).default([
|
|
207
|
+
...baseNodes
|
|
208
|
+
], layerNodes.base.source));
|
|
209
|
+
layerNodes.base.remove();
|
|
210
|
+
}
|
|
211
|
+
if (layerNodes.components) {
|
|
212
|
+
layerNodes.components.before((0, _cloneNodes).default([
|
|
213
|
+
...componentNodes
|
|
214
|
+
], layerNodes.components.source));
|
|
215
|
+
layerNodes.components.remove();
|
|
216
|
+
}
|
|
217
|
+
if (layerNodes.utilities) {
|
|
218
|
+
layerNodes.utilities.before((0, _cloneNodes).default([
|
|
219
|
+
...utilityNodes
|
|
220
|
+
], layerNodes.utilities.source));
|
|
221
|
+
layerNodes.utilities.remove();
|
|
222
|
+
}
|
|
223
|
+
if (layerNodes.variants) {
|
|
224
|
+
layerNodes.variants.before((0, _cloneNodes).default([
|
|
225
|
+
...screenNodes
|
|
226
|
+
], layerNodes.variants.source));
|
|
227
|
+
layerNodes.variants.remove();
|
|
228
|
+
} else {
|
|
229
|
+
root.append((0, _cloneNodes).default([
|
|
230
|
+
...screenNodes
|
|
231
|
+
], root.source));
|
|
232
|
+
}
|
|
233
|
+
// ---
|
|
234
|
+
if (env.DEBUG) {
|
|
235
|
+
console.log('Potential classes: ', candidates.size);
|
|
236
|
+
console.log('Active contexts: ', sharedState.contextSourcesMap.size);
|
|
237
|
+
}
|
|
238
|
+
// Clear the cache for the changed files
|
|
239
|
+
context.changedContent = [];
|
|
240
|
+
// Cleanup any leftover @layer atrules
|
|
241
|
+
root.walkAtRules('layer', (rule)=>{
|
|
242
|
+
if (Object.keys(layerNodes).includes(rule.params)) {
|
|
243
|
+
rule.remove();
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
}
|