@unocss/transformer-directives 66.7.2 → 66.7.4-beta.1
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/dist/index.mjs +7 -2
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -178,7 +178,7 @@ function handleScreen({ code, uno }, node) {
|
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/transform.ts
|
|
181
|
-
|
|
181
|
+
function resolveApplyVariables(options) {
|
|
182
182
|
let { applyVariable } = options;
|
|
183
183
|
const varStyle = options.varStyle;
|
|
184
184
|
if (applyVariable === void 0) {
|
|
@@ -189,7 +189,10 @@ async function transformDirectives(code, uno, options, filename, originalCode, o
|
|
|
189
189
|
"--uno"
|
|
190
190
|
];
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
return toArray(applyVariable || []);
|
|
193
|
+
}
|
|
194
|
+
async function transformDirectives(code, uno, options, filename, originalCode, offset) {
|
|
195
|
+
const applyVariable = resolveApplyVariables(options);
|
|
193
196
|
const isHasApply = (code) => code.includes("@apply") || applyVariable.some((s) => code.includes(s));
|
|
194
197
|
const parseCode = originalCode || code.original;
|
|
195
198
|
const hasApply = isHasApply(parseCode);
|
|
@@ -232,10 +235,12 @@ async function transformDirectives(code, uno, options, filename, originalCode, o
|
|
|
232
235
|
//#endregion
|
|
233
236
|
//#region src/index.ts
|
|
234
237
|
function transformerDirectives(options = {}) {
|
|
238
|
+
const applyVariables = resolveApplyVariables(options);
|
|
235
239
|
return {
|
|
236
240
|
name: "@unocss/transformer-directives",
|
|
237
241
|
enforce: options?.enforce,
|
|
238
242
|
idFilter: (id) => cssIdRE.test(id),
|
|
243
|
+
codeFilter: (code) => code.includes("@apply") || code.includes("@screen") || code.includes("theme(") || code.includes("icon(") || applyVariables.some((variable) => code.includes(variable)),
|
|
239
244
|
transform: (code, id, ctx) => {
|
|
240
245
|
return transformDirectives(code, ctx.uno, options, id);
|
|
241
246
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/transformer-directives",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.7.
|
|
4
|
+
"version": "66.7.4-beta.1",
|
|
5
5
|
"description": "UnoCSS transformer for `@apply` directive",
|
|
6
6
|
"author": "hannoeru <me@hanlee.co>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"css-tree": "^3.2.1",
|
|
32
|
-
"@unocss/core": "66.7.
|
|
33
|
-
"@unocss/rule-utils": "66.7.
|
|
32
|
+
"@unocss/core": "66.7.4-beta.1",
|
|
33
|
+
"@unocss/rule-utils": "66.7.4-beta.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"magic-string": "^0.30.21"
|