@unocss/postcss 0.50.6 → 0.50.7
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/README.md +5 -5
- package/dist/index.cjs +20 -20
- package/dist/index.mjs +20 -20
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# @unocss/postcss
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
This package is in an experimental state right now. It doesn't follow semver, and may introduce breaking changes in patch versions.
|
|
3
|
+
PostCSS plugin for UnoCSS. Supports `@apply`、`@screen` and `theme()` directives.
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
> **Warning**: Experimental
|
|
6
|
+
> This package is in an experimental state right now. It doesn't follow semver, and may introduce breaking changes in patch versions.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
<!-- @unocss-ignore -->
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
// uno.config.
|
|
29
|
+
// uno.config.ts
|
|
30
30
|
import { defineConfig, presetUno } from 'unocss'
|
|
31
31
|
|
|
32
32
|
export default defineConfig({
|
package/dist/index.cjs
CHANGED
|
@@ -78,7 +78,9 @@ async function parseApply(root, uno, directiveName) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
function themeFnRE(directiveName) {
|
|
82
|
+
return new RegExp(`${directiveName}\\((.*?)\\)`, "g");
|
|
83
|
+
}
|
|
82
84
|
async function parseTheme(root, uno, directiveName) {
|
|
83
85
|
root.walkDecls((decl) => {
|
|
84
86
|
const matches = Array.from(decl.value.matchAll(themeFnRE(directiveName)));
|
|
@@ -187,32 +189,36 @@ function unocss(options = {}) {
|
|
|
187
189
|
postcssPlugin: directiveMap.unocss,
|
|
188
190
|
plugins: [
|
|
189
191
|
async function(root, result) {
|
|
190
|
-
|
|
192
|
+
const from = result.opts.from?.split("?")[0];
|
|
193
|
+
if (!from)
|
|
191
194
|
return;
|
|
192
|
-
let isTarget =
|
|
195
|
+
let isTarget = targetCache.has(from);
|
|
196
|
+
const isScanTarget = root.toString().includes(`@${directiveMap.unocss}`);
|
|
193
197
|
if (targetRE.test(root.toString())) {
|
|
194
|
-
if (!
|
|
198
|
+
if (!isTarget) {
|
|
195
199
|
root.walkAtRules((rule) => {
|
|
196
|
-
if (rule.name === directiveMap.unocss || rule.name === directiveMap.apply || rule.name === directiveMap.
|
|
200
|
+
if (rule.name === directiveMap.unocss || rule.name === directiveMap.apply || rule.name === directiveMap.screen)
|
|
197
201
|
isTarget = true;
|
|
202
|
+
if (isTarget)
|
|
203
|
+
return false;
|
|
198
204
|
});
|
|
199
205
|
if (!isTarget) {
|
|
200
206
|
const themeFn = themeFnRE(directiveMap.theme);
|
|
201
207
|
root.walkDecls((decl) => {
|
|
202
|
-
if (themeFn.test(decl.value))
|
|
208
|
+
if (themeFn.test(decl.value)) {
|
|
203
209
|
isTarget = true;
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
204
212
|
});
|
|
213
|
+
} else {
|
|
214
|
+
targetCache.add(from);
|
|
205
215
|
}
|
|
206
|
-
} else {
|
|
207
|
-
isTarget = true;
|
|
208
216
|
}
|
|
209
|
-
} else if (targetCache.has(
|
|
210
|
-
targetCache.delete(
|
|
217
|
+
} else if (targetCache.has(from)) {
|
|
218
|
+
targetCache.delete(from);
|
|
211
219
|
}
|
|
212
220
|
if (!isTarget)
|
|
213
221
|
return;
|
|
214
|
-
else
|
|
215
|
-
targetCache.add(result.opts.from);
|
|
216
222
|
try {
|
|
217
223
|
const cfg = await config$1;
|
|
218
224
|
if (!uno) {
|
|
@@ -229,19 +235,13 @@ function unocss(options = {}) {
|
|
|
229
235
|
}
|
|
230
236
|
const globs = content?.filter((v) => typeof v === "string") ?? defaultIncludeGlobs;
|
|
231
237
|
const rawContent = content?.filter((v) => typeof v === "object") ?? [];
|
|
232
|
-
const entries = await fg__default(globs, {
|
|
238
|
+
const entries = await fg__default(isScanTarget ? globs : from, {
|
|
233
239
|
cwd,
|
|
234
240
|
dot: true,
|
|
235
241
|
absolute: true,
|
|
236
242
|
ignore: ["**/{.git,node_modules}/**"],
|
|
237
243
|
stats: true
|
|
238
244
|
});
|
|
239
|
-
result.messages.push({
|
|
240
|
-
type: "dependency",
|
|
241
|
-
plugin: directiveMap.unocss,
|
|
242
|
-
file: result.opts.from,
|
|
243
|
-
parent: result.opts.from
|
|
244
|
-
});
|
|
245
245
|
await parseApply(root, uno, directiveMap.apply);
|
|
246
246
|
await parseTheme(root, uno, directiveMap.theme);
|
|
247
247
|
await parseScreen(root, uno, directiveMap.screen);
|
|
@@ -258,7 +258,7 @@ function unocss(options = {}) {
|
|
|
258
258
|
type: "dependency",
|
|
259
259
|
plugin: directiveMap.unocss,
|
|
260
260
|
file: node_path.normalize(file),
|
|
261
|
-
parent:
|
|
261
|
+
parent: from
|
|
262
262
|
});
|
|
263
263
|
if (fileMap.has(file) && mtimeMs <= fileMap.get(file))
|
|
264
264
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -70,7 +70,9 @@ async function parseApply(root, uno, directiveName) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
function themeFnRE(directiveName) {
|
|
74
|
+
return new RegExp(`${directiveName}\\((.*?)\\)`, "g");
|
|
75
|
+
}
|
|
74
76
|
async function parseTheme(root, uno, directiveName) {
|
|
75
77
|
root.walkDecls((decl) => {
|
|
76
78
|
const matches = Array.from(decl.value.matchAll(themeFnRE(directiveName)));
|
|
@@ -179,32 +181,36 @@ function unocss(options = {}) {
|
|
|
179
181
|
postcssPlugin: directiveMap.unocss,
|
|
180
182
|
plugins: [
|
|
181
183
|
async function(root, result) {
|
|
182
|
-
|
|
184
|
+
const from = result.opts.from?.split("?")[0];
|
|
185
|
+
if (!from)
|
|
183
186
|
return;
|
|
184
|
-
let isTarget =
|
|
187
|
+
let isTarget = targetCache.has(from);
|
|
188
|
+
const isScanTarget = root.toString().includes(`@${directiveMap.unocss}`);
|
|
185
189
|
if (targetRE.test(root.toString())) {
|
|
186
|
-
if (!
|
|
190
|
+
if (!isTarget) {
|
|
187
191
|
root.walkAtRules((rule) => {
|
|
188
|
-
if (rule.name === directiveMap.unocss || rule.name === directiveMap.apply || rule.name === directiveMap.
|
|
192
|
+
if (rule.name === directiveMap.unocss || rule.name === directiveMap.apply || rule.name === directiveMap.screen)
|
|
189
193
|
isTarget = true;
|
|
194
|
+
if (isTarget)
|
|
195
|
+
return false;
|
|
190
196
|
});
|
|
191
197
|
if (!isTarget) {
|
|
192
198
|
const themeFn = themeFnRE(directiveMap.theme);
|
|
193
199
|
root.walkDecls((decl) => {
|
|
194
|
-
if (themeFn.test(decl.value))
|
|
200
|
+
if (themeFn.test(decl.value)) {
|
|
195
201
|
isTarget = true;
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
196
204
|
});
|
|
205
|
+
} else {
|
|
206
|
+
targetCache.add(from);
|
|
197
207
|
}
|
|
198
|
-
} else {
|
|
199
|
-
isTarget = true;
|
|
200
208
|
}
|
|
201
|
-
} else if (targetCache.has(
|
|
202
|
-
targetCache.delete(
|
|
209
|
+
} else if (targetCache.has(from)) {
|
|
210
|
+
targetCache.delete(from);
|
|
203
211
|
}
|
|
204
212
|
if (!isTarget)
|
|
205
213
|
return;
|
|
206
|
-
else
|
|
207
|
-
targetCache.add(result.opts.from);
|
|
208
214
|
try {
|
|
209
215
|
const cfg = await config;
|
|
210
216
|
if (!uno) {
|
|
@@ -221,19 +227,13 @@ function unocss(options = {}) {
|
|
|
221
227
|
}
|
|
222
228
|
const globs = content?.filter((v) => typeof v === "string") ?? defaultIncludeGlobs;
|
|
223
229
|
const rawContent = content?.filter((v) => typeof v === "object") ?? [];
|
|
224
|
-
const entries = await fg(globs, {
|
|
230
|
+
const entries = await fg(isScanTarget ? globs : from, {
|
|
225
231
|
cwd,
|
|
226
232
|
dot: true,
|
|
227
233
|
absolute: true,
|
|
228
234
|
ignore: ["**/{.git,node_modules}/**"],
|
|
229
235
|
stats: true
|
|
230
236
|
});
|
|
231
|
-
result.messages.push({
|
|
232
|
-
type: "dependency",
|
|
233
|
-
plugin: directiveMap.unocss,
|
|
234
|
-
file: result.opts.from,
|
|
235
|
-
parent: result.opts.from
|
|
236
|
-
});
|
|
237
237
|
await parseApply(root, uno, directiveMap.apply);
|
|
238
238
|
await parseTheme(root, uno, directiveMap.theme);
|
|
239
239
|
await parseScreen(root, uno, directiveMap.screen);
|
|
@@ -250,7 +250,7 @@ function unocss(options = {}) {
|
|
|
250
250
|
type: "dependency",
|
|
251
251
|
plugin: directiveMap.unocss,
|
|
252
252
|
file: normalize(file),
|
|
253
|
-
parent:
|
|
253
|
+
parent: from
|
|
254
254
|
});
|
|
255
255
|
if (fileMap.has(file) && mtimeMs <= fileMap.get(file))
|
|
256
256
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/postcss",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.7",
|
|
4
4
|
"description": "PostCSS plugin for UnoCSS",
|
|
5
5
|
"author": "sibbng <sibbngheid@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"fast-glob": "^3.2.12",
|
|
41
41
|
"magic-string": "^0.30.0",
|
|
42
42
|
"postcss": "^8.4.21",
|
|
43
|
-
"@unocss/config": "0.50.
|
|
44
|
-
"@unocss/core": "0.50.
|
|
43
|
+
"@unocss/config": "0.50.7",
|
|
44
|
+
"@unocss/core": "0.50.7"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "unbuild",
|