@unocss/extractor-pug 0.58.9 → 0.59.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/package.json +6 -6
- package/dist/index.cjs +0 -41
- package/dist/index.d.cts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/extractor-pug",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.59.0",
|
|
4
5
|
"description": "UnoCSS extractor for Pug",
|
|
5
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
7
|
"license": "MIT",
|
|
@@ -22,12 +23,11 @@
|
|
|
22
23
|
"sideEffects": false,
|
|
23
24
|
"exports": {
|
|
24
25
|
".": {
|
|
25
|
-
"types": "./dist/index.d.
|
|
26
|
-
"
|
|
27
|
-
"require": "./dist/index.cjs"
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"main": "./dist/index.
|
|
30
|
+
"main": "./dist/index.mjs",
|
|
31
31
|
"module": "./dist/index.mjs",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"files": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/pug": "^2.0.10",
|
|
46
46
|
"pug": "^3.0.2",
|
|
47
|
-
"@unocss/core": "0.
|
|
47
|
+
"@unocss/core": "0.59.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "unbuild",
|
package/dist/index.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const regexVueTemplate = /<template.*?lang=['"]pug['"][^>]*?>\s*([\s\S]*?\s*)<\/template>/gm;
|
|
4
|
-
function extractorPug(options = {}) {
|
|
5
|
-
async function compile(code, id) {
|
|
6
|
-
const Pug = await import('pug');
|
|
7
|
-
try {
|
|
8
|
-
return Pug.compile(code, { filename: id, doctype: "html", ...options })();
|
|
9
|
-
} catch {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
name: "pug",
|
|
14
|
-
order: -1,
|
|
15
|
-
async extract(ctx) {
|
|
16
|
-
if (!ctx.id)
|
|
17
|
-
return;
|
|
18
|
-
if (ctx.id.endsWith(".pug") || ctx.id.includes("?vue&type=template")) {
|
|
19
|
-
try {
|
|
20
|
-
ctx.code = await compile(ctx.code, ctx.id) || ctx.code;
|
|
21
|
-
} catch {
|
|
22
|
-
}
|
|
23
|
-
} else if (ctx.id.endsWith(".vue")) {
|
|
24
|
-
const matches = Array.from(ctx.code.matchAll(regexVueTemplate));
|
|
25
|
-
let tail = "";
|
|
26
|
-
for (const match of matches) {
|
|
27
|
-
if (match && match[1])
|
|
28
|
-
tail += `
|
|
29
|
-
${await compile(match[1], ctx.id)}`;
|
|
30
|
-
}
|
|
31
|
-
if (tail)
|
|
32
|
-
ctx.code = `${ctx.code}
|
|
33
|
-
|
|
34
|
-
${tail}`;
|
|
35
|
-
}
|
|
36
|
-
return void 0;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = extractorPug;
|