tailwindcss 0.0.0-insiders.7c337f2 → 0.0.0-insiders.7d8eb21
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 +246 -6
- package/README.md +13 -9
- package/defaultTheme.d.ts +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +362 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli-peer-dependencies.js +18 -5
- package/lib/cli.js +62 -592
- package/lib/constants.js +19 -12
- package/lib/corePluginList.js +5 -3
- package/lib/corePlugins.js +619 -347
- package/lib/css/preflight.css +7 -0
- package/lib/featureFlags.js +34 -22
- package/lib/index.js +16 -9
- package/lib/lib/cacheInvalidation.js +42 -21
- package/lib/lib/collapseAdjacentRules.js +16 -14
- package/lib/lib/collapseDuplicateDeclarations.js +13 -10
- package/lib/lib/content.js +177 -0
- package/lib/lib/defaultExtractor.js +230 -33
- package/lib/lib/detectNesting.js +13 -4
- package/lib/lib/evaluateTailwindFunctions.js +105 -42
- package/lib/lib/expandApplyAtRules.js +151 -92
- package/lib/lib/expandTailwindAtRules.js +134 -149
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +404 -185
- package/lib/lib/getModuleDependencies.js +21 -18
- package/lib/lib/normalizeTailwindDirectives.js +11 -8
- package/lib/lib/offsets.js +285 -0
- package/lib/lib/partitionApplyAtRules.js +14 -11
- package/lib/lib/regex.js +60 -0
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +97 -79
- package/lib/lib/setupContextUtils.js +567 -242
- package/lib/lib/setupTrackingContext.js +77 -106
- package/lib/lib/sharedState.js +18 -10
- package/lib/lib/substituteScreenAtRules.js +9 -7
- package/lib/postcss-plugins/nesting/index.js +7 -5
- package/lib/postcss-plugins/nesting/plugin.js +10 -8
- package/lib/processTailwindFeatures.js +34 -31
- package/lib/public/colors.js +7 -5
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +13 -10
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +10 -5
- package/lib/util/cloneDeep.js +6 -5
- package/lib/util/cloneNodes.js +9 -2
- package/lib/util/color.js +20 -17
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -5
- package/lib/util/createUtilityPlugin.js +15 -13
- package/lib/util/dataTypes.js +75 -51
- package/lib/util/defaults.js +8 -5
- package/lib/util/escapeClassName.js +13 -10
- package/lib/util/escapeCommas.js +4 -1
- package/lib/util/flattenColorPalette.js +7 -8
- package/lib/util/formatVariantSelector.js +270 -103
- package/lib/util/getAllConfigs.js +34 -15
- package/lib/util/hashConfig.js +10 -7
- package/lib/util/isKeyframeRule.js +4 -1
- package/lib/util/isPlainObject.js +4 -1
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +34 -26
- package/lib/util/log.js +14 -8
- package/lib/util/nameClass.js +19 -8
- package/lib/util/negateValue.js +20 -5
- package/lib/util/normalizeConfig.js +94 -53
- package/lib/util/normalizeScreens.js +115 -4
- package/lib/util/parseAnimationValue.js +43 -41
- package/lib/util/parseBoxShadowValue.js +12 -45
- package/lib/util/parseDependency.js +37 -55
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +15 -12
- package/lib/util/pluginUtils.js +146 -42
- package/lib/util/prefixSelector.js +26 -9
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +104 -105
- package/lib/util/resolveConfigPath.js +20 -17
- package/lib/util/responsive.js +12 -9
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +4 -1
- package/lib/util/toPath.js +18 -2
- package/lib/util/transformThemeValue.js +23 -11
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +32 -24
- package/package.json +32 -29
- package/peers/index.js +6693 -3036
- package/plugin.d.ts +10 -5
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +53 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +434 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +46 -659
- package/src/corePlugins.js +346 -79
- package/src/css/preflight.css +7 -0
- package/src/featureFlags.js +12 -2
- package/src/index.js +5 -0
- package/src/lib/content.js +213 -0
- package/src/lib/defaultExtractor.js +202 -35
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +129 -34
- package/src/lib/expandTailwindAtRules.js +12 -50
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +379 -126
- package/src/lib/offsets.js +351 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +510 -120
- package/src/lib/setupTrackingContext.js +8 -45
- package/src/lib/sharedState.js +2 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +5 -1
- package/src/util/dataTypes.js +51 -26
- package/src/util/formatVariantSelector.js +317 -101
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +1 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +40 -10
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +28 -10
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -62
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +165 -164
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +77 -37
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -1
- package/types.d.ts +0 -1
|
@@ -2,14 +2,124 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>expandTailwindAtRules
|
|
8
|
+
});
|
|
9
|
+
const _quickLru = /*#__PURE__*/ _interopRequireDefault(require("quick-lru"));
|
|
10
|
+
const _sharedState = /*#__PURE__*/ _interopRequireWildcard(require("./sharedState"));
|
|
11
|
+
const _generateRules = require("./generateRules");
|
|
12
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../util/log"));
|
|
13
|
+
const _cloneNodes = /*#__PURE__*/ _interopRequireDefault(require("../util/cloneNodes"));
|
|
14
|
+
const _defaultExtractor = require("./defaultExtractor");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
}
|
|
59
|
+
let env = _sharedState.env;
|
|
60
|
+
const builtInExtractors = {
|
|
61
|
+
DEFAULT: _defaultExtractor.defaultExtractor
|
|
62
|
+
};
|
|
63
|
+
const builtInTransformers = {
|
|
64
|
+
DEFAULT: (content)=>content,
|
|
65
|
+
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
66
|
+
};
|
|
67
|
+
function getExtractor(context, fileExtension) {
|
|
68
|
+
let extractors = context.tailwindConfig.content.extract;
|
|
69
|
+
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT(context);
|
|
70
|
+
}
|
|
71
|
+
function getTransformer(tailwindConfig, fileExtension) {
|
|
72
|
+
let transformers = tailwindConfig.content.transform;
|
|
73
|
+
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
74
|
+
}
|
|
75
|
+
let extractorCache = new WeakMap();
|
|
76
|
+
// Scans template contents for possible classes. This is a hot path on initial build but
|
|
77
|
+
// not too important for subsequent builds. The faster the better though — if we can speed
|
|
78
|
+
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
79
|
+
function getClassCandidates(content, extractor, candidates, seen) {
|
|
80
|
+
if (!extractorCache.has(extractor)) {
|
|
81
|
+
extractorCache.set(extractor, new _quickLru.default({
|
|
82
|
+
maxSize: 25000
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
for (let line of content.split("\n")){
|
|
86
|
+
line = line.trim();
|
|
87
|
+
if (seen.has(line)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
seen.add(line);
|
|
91
|
+
if (extractorCache.get(extractor).has(line)) {
|
|
92
|
+
for (let match of extractorCache.get(extractor).get(line)){
|
|
93
|
+
candidates.add(match);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
let extractorMatches = extractor(line).filter((s)=>s !== "!*");
|
|
97
|
+
let lineMatchesSet = new Set(extractorMatches);
|
|
98
|
+
for (let match1 of lineMatchesSet){
|
|
99
|
+
candidates.add(match1);
|
|
100
|
+
}
|
|
101
|
+
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {[import('./offsets.js').RuleOffset, import('postcss').Node][]} rules
|
|
108
|
+
* @param {*} context
|
|
109
|
+
*/ function buildStylesheet(rules, context) {
|
|
110
|
+
let sortedRules = context.offsets.sort(rules);
|
|
111
|
+
let returnValue = {
|
|
112
|
+
base: new Set(),
|
|
113
|
+
defaults: new Set(),
|
|
114
|
+
components: new Set(),
|
|
115
|
+
utilities: new Set(),
|
|
116
|
+
variants: new Set()
|
|
117
|
+
};
|
|
118
|
+
for (let [sort, rule] of sortedRules){
|
|
119
|
+
returnValue[sort.layer].add(rule);
|
|
120
|
+
}
|
|
121
|
+
return returnValue;
|
|
122
|
+
}
|
|
13
123
|
function expandTailwindAtRules(context) {
|
|
14
124
|
return (root)=>{
|
|
15
125
|
let layerNodes = {
|
|
@@ -29,20 +139,19 @@ function expandTailwindAtRules(context) {
|
|
|
29
139
|
}
|
|
30
140
|
}
|
|
31
141
|
});
|
|
32
|
-
if (Object.values(layerNodes).every((n)=>n === null
|
|
33
|
-
)) {
|
|
142
|
+
if (Object.values(layerNodes).every((n)=>n === null)) {
|
|
34
143
|
return root;
|
|
35
144
|
}
|
|
36
145
|
// ---
|
|
37
146
|
// Find potential rules in changed files
|
|
38
147
|
let candidates = new Set([
|
|
39
|
-
|
|
148
|
+
_sharedState.NOT_ON_DEMAND
|
|
40
149
|
]);
|
|
41
150
|
let seen = new Set();
|
|
42
151
|
env.DEBUG && console.time("Reading changed files");
|
|
43
152
|
for (let { content , extension } of context.changedContent){
|
|
44
153
|
let transformer = getTransformer(context.tailwindConfig, extension);
|
|
45
|
-
let extractor = getExtractor(context
|
|
154
|
+
let extractor = getExtractor(context, extension);
|
|
46
155
|
getClassCandidates(transformer(content), extractor, candidates, seen);
|
|
47
156
|
}
|
|
48
157
|
env.DEBUG && console.timeEnd("Reading changed files");
|
|
@@ -50,24 +159,21 @@ function expandTailwindAtRules(context) {
|
|
|
50
159
|
// Generate the actual CSS
|
|
51
160
|
let classCacheCount = context.classCache.size;
|
|
52
161
|
env.DEBUG && console.time("Generate rules");
|
|
53
|
-
|
|
162
|
+
(0, _generateRules.generateRules)(candidates, context);
|
|
54
163
|
env.DEBUG && console.timeEnd("Generate rules");
|
|
55
164
|
// We only ever add to the classCache, so if it didn't grow, there is nothing new.
|
|
56
165
|
env.DEBUG && console.time("Build stylesheet");
|
|
57
166
|
if (context.stylesheetCache === null || context.classCache.size !== classCacheCount) {
|
|
58
|
-
for (let rule of rules){
|
|
59
|
-
context.ruleCache.add(rule);
|
|
60
|
-
}
|
|
61
167
|
context.stylesheetCache = buildStylesheet([
|
|
62
168
|
...context.ruleCache
|
|
63
169
|
], context);
|
|
64
170
|
}
|
|
65
171
|
env.DEBUG && console.timeEnd("Build stylesheet");
|
|
66
|
-
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes
|
|
172
|
+
let { defaults: defaultNodes , base: baseNodes , components: componentNodes , utilities: utilityNodes , variants: screenNodes } = context.stylesheetCache;
|
|
67
173
|
// ---
|
|
68
174
|
// Replace any Tailwind directives with generated CSS
|
|
69
175
|
if (layerNodes.base) {
|
|
70
|
-
layerNodes.base.before((0, _cloneNodes
|
|
176
|
+
layerNodes.base.before((0, _cloneNodes.default)([
|
|
71
177
|
...baseNodes,
|
|
72
178
|
...defaultNodes
|
|
73
179
|
], layerNodes.base.source, {
|
|
@@ -76,7 +182,7 @@ function expandTailwindAtRules(context) {
|
|
|
76
182
|
layerNodes.base.remove();
|
|
77
183
|
}
|
|
78
184
|
if (layerNodes.components) {
|
|
79
|
-
layerNodes.components.before((0, _cloneNodes
|
|
185
|
+
layerNodes.components.before((0, _cloneNodes.default)([
|
|
80
186
|
...componentNodes
|
|
81
187
|
], layerNodes.components.source, {
|
|
82
188
|
layer: "components"
|
|
@@ -84,7 +190,7 @@ function expandTailwindAtRules(context) {
|
|
|
84
190
|
layerNodes.components.remove();
|
|
85
191
|
}
|
|
86
192
|
if (layerNodes.utilities) {
|
|
87
|
-
layerNodes.utilities.before((0, _cloneNodes
|
|
193
|
+
layerNodes.utilities.before((0, _cloneNodes.default)([
|
|
88
194
|
...utilityNodes
|
|
89
195
|
], layerNodes.utilities.source, {
|
|
90
196
|
layer: "utilities"
|
|
@@ -93,8 +199,8 @@ function expandTailwindAtRules(context) {
|
|
|
93
199
|
}
|
|
94
200
|
// We do post-filtering to not alter the emitted order of the variants
|
|
95
201
|
const variantNodes = Array.from(screenNodes).filter((node)=>{
|
|
96
|
-
var
|
|
97
|
-
const parentLayer = (
|
|
202
|
+
var _node_raws_tailwind;
|
|
203
|
+
const parentLayer = (_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer;
|
|
98
204
|
if (parentLayer === "components") {
|
|
99
205
|
return layerNodes.components !== null;
|
|
100
206
|
}
|
|
@@ -104,30 +210,30 @@ function expandTailwindAtRules(context) {
|
|
|
104
210
|
return true;
|
|
105
211
|
});
|
|
106
212
|
if (layerNodes.variants) {
|
|
107
|
-
layerNodes.variants.before((0, _cloneNodes
|
|
213
|
+
layerNodes.variants.before((0, _cloneNodes.default)(variantNodes, layerNodes.variants.source, {
|
|
108
214
|
layer: "variants"
|
|
109
215
|
}));
|
|
110
216
|
layerNodes.variants.remove();
|
|
111
217
|
} else if (variantNodes.length > 0) {
|
|
112
|
-
root.append((0, _cloneNodes
|
|
218
|
+
root.append((0, _cloneNodes.default)(variantNodes, root.source, {
|
|
113
219
|
layer: "variants"
|
|
114
220
|
}));
|
|
115
221
|
}
|
|
116
222
|
// If we've got a utility layer and no utilities are generated there's likely something wrong
|
|
117
223
|
const hasUtilityVariants = variantNodes.some((node)=>{
|
|
118
|
-
var
|
|
119
|
-
return ((
|
|
224
|
+
var _node_raws_tailwind;
|
|
225
|
+
return ((_node_raws_tailwind = node.raws.tailwind) === null || _node_raws_tailwind === void 0 ? void 0 : _node_raws_tailwind.parentLayer) === "utilities";
|
|
120
226
|
});
|
|
121
227
|
if (layerNodes.utilities && utilityNodes.size === 0 && !hasUtilityVariants) {
|
|
122
228
|
_log.default.warn("content-problems", [
|
|
123
229
|
"No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.",
|
|
124
|
-
"https://tailwindcss.com/docs/content-configuration"
|
|
230
|
+
"https://tailwindcss.com/docs/content-configuration"
|
|
125
231
|
]);
|
|
126
232
|
}
|
|
127
233
|
// ---
|
|
128
234
|
if (env.DEBUG) {
|
|
129
235
|
console.log("Potential classes: ", candidates.size);
|
|
130
|
-
console.log("Active contexts: ",
|
|
236
|
+
console.log("Active contexts: ", _sharedState.contextSourcesMap.size);
|
|
131
237
|
}
|
|
132
238
|
// Clear the cache for the changed files
|
|
133
239
|
context.changedContent = [];
|
|
@@ -139,124 +245,3 @@ function expandTailwindAtRules(context) {
|
|
|
139
245
|
});
|
|
140
246
|
};
|
|
141
247
|
}
|
|
142
|
-
function _interopRequireDefault(obj) {
|
|
143
|
-
return obj && obj.__esModule ? obj : {
|
|
144
|
-
default: obj
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function _interopRequireWildcard(obj) {
|
|
148
|
-
if (obj && obj.__esModule) {
|
|
149
|
-
return obj;
|
|
150
|
-
} else {
|
|
151
|
-
var newObj = {};
|
|
152
|
-
if (obj != null) {
|
|
153
|
-
for(var key in obj){
|
|
154
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
155
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
156
|
-
if (desc.get || desc.set) {
|
|
157
|
-
Object.defineProperty(newObj, key, desc);
|
|
158
|
-
} else {
|
|
159
|
-
newObj[key] = obj[key];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
newObj.default = obj;
|
|
165
|
-
return newObj;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
let env = sharedState.env;
|
|
169
|
-
const builtInExtractors = {
|
|
170
|
-
DEFAULT: _defaultExtractor.defaultExtractor
|
|
171
|
-
};
|
|
172
|
-
const builtInTransformers = {
|
|
173
|
-
DEFAULT: (content)=>content
|
|
174
|
-
,
|
|
175
|
-
svelte: (content)=>content.replace(/(?:^|\s)class:/g, " ")
|
|
176
|
-
};
|
|
177
|
-
function getExtractor(tailwindConfig, fileExtension) {
|
|
178
|
-
let extractors = tailwindConfig.content.extract;
|
|
179
|
-
return extractors[fileExtension] || extractors.DEFAULT || builtInExtractors[fileExtension] || builtInExtractors.DEFAULT;
|
|
180
|
-
}
|
|
181
|
-
function getTransformer(tailwindConfig, fileExtension) {
|
|
182
|
-
let transformers = tailwindConfig.content.transform;
|
|
183
|
-
return transformers[fileExtension] || transformers.DEFAULT || builtInTransformers[fileExtension] || builtInTransformers.DEFAULT;
|
|
184
|
-
}
|
|
185
|
-
let extractorCache = new WeakMap();
|
|
186
|
-
// Scans template contents for possible classes. This is a hot path on initial build but
|
|
187
|
-
// not too important for subsequent builds. The faster the better though — if we can speed
|
|
188
|
-
// up these regexes by 50% that could cut initial build time by like 20%.
|
|
189
|
-
function getClassCandidates(content, extractor, candidates, seen) {
|
|
190
|
-
if (!extractorCache.has(extractor)) {
|
|
191
|
-
extractorCache.set(extractor, new _quickLru.default({
|
|
192
|
-
maxSize: 25000
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
for (let line of content.split("\n")){
|
|
196
|
-
line = line.trim();
|
|
197
|
-
if (seen.has(line)) {
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
seen.add(line);
|
|
201
|
-
if (extractorCache.get(extractor).has(line)) {
|
|
202
|
-
for (let match of extractorCache.get(extractor).get(line)){
|
|
203
|
-
candidates.add(match);
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
let extractorMatches = extractor(line).filter((s)=>s !== "!*"
|
|
207
|
-
);
|
|
208
|
-
let lineMatchesSet = new Set(extractorMatches);
|
|
209
|
-
for (let match of lineMatchesSet){
|
|
210
|
-
candidates.add(match);
|
|
211
|
-
}
|
|
212
|
-
extractorCache.get(extractor).set(line, lineMatchesSet);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function buildStylesheet(rules, context) {
|
|
217
|
-
let sortedRules = rules.sort(([a], [z])=>(0, _bigSign).default(a - z)
|
|
218
|
-
);
|
|
219
|
-
let returnValue = {
|
|
220
|
-
base: new Set(),
|
|
221
|
-
defaults: new Set(),
|
|
222
|
-
components: new Set(),
|
|
223
|
-
utilities: new Set(),
|
|
224
|
-
variants: new Set(),
|
|
225
|
-
// All the CSS that is not Tailwind related can be put in this bucket. This
|
|
226
|
-
// will make it easier to later use this information when we want to
|
|
227
|
-
// `@apply` for example. The main reason we do this here is because we
|
|
228
|
-
// still need to make sure the order is correct. Last but not least, we
|
|
229
|
-
// will make sure to always re-inject this section into the css, even if
|
|
230
|
-
// certain rules were not used. This means that it will look like a no-op
|
|
231
|
-
// from the user's perspective, but we gathered all the useful information
|
|
232
|
-
// we need.
|
|
233
|
-
user: new Set()
|
|
234
|
-
};
|
|
235
|
-
for (let [sort, rule] of sortedRules){
|
|
236
|
-
if (sort >= context.minimumScreen) {
|
|
237
|
-
returnValue.variants.add(rule);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (sort & context.layerOrder.base) {
|
|
241
|
-
returnValue.base.add(rule);
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
if (sort & context.layerOrder.defaults) {
|
|
245
|
-
returnValue.defaults.add(rule);
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
if (sort & context.layerOrder.components) {
|
|
249
|
-
returnValue.components.add(rule);
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
if (sort & context.layerOrder.utilities) {
|
|
253
|
-
returnValue.utilities.add(rule);
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
if (sort & context.layerOrder.user) {
|
|
257
|
-
returnValue.user.add(rule);
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return returnValue;
|
|
262
|
-
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "findAtConfigPath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>findAtConfigPath
|
|
8
|
+
});
|
|
9
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
10
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function findAtConfigPath(root, result) {
|
|
17
|
+
let configPath = null;
|
|
18
|
+
let relativeTo = null;
|
|
19
|
+
root.walkAtRules("config", (rule)=>{
|
|
20
|
+
var _rule_source;
|
|
21
|
+
var _rule_source_input_file, _ref;
|
|
22
|
+
relativeTo = (_ref = (_rule_source_input_file = (_rule_source = rule.source) === null || _rule_source === void 0 ? void 0 : _rule_source.input.file) !== null && _rule_source_input_file !== void 0 ? _rule_source_input_file : result.opts.from) !== null && _ref !== void 0 ? _ref : null;
|
|
23
|
+
if (relativeTo === null) {
|
|
24
|
+
throw rule.error("The `@config` directive cannot be used without setting `from` in your PostCSS config.");
|
|
25
|
+
}
|
|
26
|
+
if (configPath) {
|
|
27
|
+
throw rule.error("Only one `@config` directive is allowed per file.");
|
|
28
|
+
}
|
|
29
|
+
let matches = rule.params.match(/(['"])(.*?)\1/);
|
|
30
|
+
if (!matches) {
|
|
31
|
+
throw rule.error("A path is required when using the `@config` directive.");
|
|
32
|
+
}
|
|
33
|
+
let inputPath = matches[2];
|
|
34
|
+
if (_path.default.isAbsolute(inputPath)) {
|
|
35
|
+
throw rule.error("The `@config` directive cannot be used with an absolute path.");
|
|
36
|
+
}
|
|
37
|
+
configPath = _path.default.resolve(_path.default.dirname(relativeTo), inputPath);
|
|
38
|
+
if (!_fs.default.existsSync(configPath)) {
|
|
39
|
+
throw rule.error(`The config file at "${inputPath}" does not exist. Make sure the path is correct and the file exists.`);
|
|
40
|
+
}
|
|
41
|
+
rule.remove();
|
|
42
|
+
});
|
|
43
|
+
return configPath ? configPath : null;
|
|
44
|
+
}
|