@unocss/astro 0.53.0 → 0.53.3
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.cjs +39 -10
- package/dist/index.mjs +39 -10
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -10,31 +10,59 @@ const VitePlugin__default = /*#__PURE__*/_interopDefaultLegacy(VitePlugin);
|
|
|
10
10
|
|
|
11
11
|
const UNO_INJECT_ID = "uno-astro";
|
|
12
12
|
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
13
|
+
const astroCSSKeyRE = /(\?|\&)lang\.css/;
|
|
13
14
|
function AstroVitePlugin(options) {
|
|
14
|
-
const { injects } = options;
|
|
15
|
-
|
|
15
|
+
const { injects, injectReset } = options;
|
|
16
|
+
const resetInjectPath = injectReset ? injects[0] : void 0;
|
|
17
|
+
let command;
|
|
18
|
+
let nodeModulesPath;
|
|
19
|
+
let resetCSSInjected = false;
|
|
20
|
+
const resolveCSSQueue = /* @__PURE__ */ new Set();
|
|
16
21
|
return {
|
|
17
22
|
name: "unocss:astro",
|
|
18
23
|
enforce: "pre",
|
|
19
|
-
configResolved(
|
|
20
|
-
|
|
24
|
+
configResolved(config) {
|
|
25
|
+
command = config.command;
|
|
26
|
+
nodeModulesPath = `${config.root}/node_modules`;
|
|
21
27
|
},
|
|
22
28
|
async resolveId(id, importer) {
|
|
23
|
-
if (id === UNO_INJECT_ID)
|
|
29
|
+
if (id === UNO_INJECT_ID) {
|
|
30
|
+
if (injectReset) {
|
|
31
|
+
resetCSSInjected = false;
|
|
32
|
+
}
|
|
24
33
|
return id;
|
|
25
|
-
|
|
34
|
+
}
|
|
35
|
+
if (injectReset && command === "serve" && astroCSSKeyRE.test(id) && !resetCSSInjected)
|
|
36
|
+
return new Promise((resolve2) => resolveCSSQueue.add(() => resolve2()));
|
|
37
|
+
if (importer?.endsWith(UNO_INJECT_ID) && command === "serve") {
|
|
26
38
|
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
27
39
|
if (resolved) {
|
|
28
40
|
const fsPath = resolved.id;
|
|
29
|
-
|
|
41
|
+
const realId = `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
42
|
+
if (injectReset) {
|
|
43
|
+
if (resetInjectPath.includes(id)) {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
resolveCSSQueue.forEach((res) => {
|
|
46
|
+
res();
|
|
47
|
+
resolveCSSQueue.delete(res);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
resetCSSInjected = true;
|
|
51
|
+
} else if (id.includes(".css") && !resetCSSInjected) {
|
|
52
|
+
return new Promise((resolve2) => {
|
|
53
|
+
resolveCSSQueue.add(() => resolve2(realId));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return realId;
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
},
|
|
33
61
|
load(id, options2) {
|
|
34
62
|
if (id.endsWith(UNO_INJECT_ID))
|
|
35
63
|
return injects.join("\n");
|
|
36
|
-
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css"))
|
|
37
|
-
return
|
|
64
|
+
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css") && !id.startsWith(nodeModulesPath))
|
|
65
|
+
return "";
|
|
38
66
|
}
|
|
39
67
|
};
|
|
40
68
|
}
|
|
@@ -56,7 +84,7 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
56
84
|
const injects = [];
|
|
57
85
|
if (injectReset) {
|
|
58
86
|
const resetPath = typeof injectReset === "string" ? injectReset : "@unocss/reset/tailwind.css";
|
|
59
|
-
injects.push(`import
|
|
87
|
+
injects.push(`import ${JSON.stringify(resetPath)}`);
|
|
60
88
|
}
|
|
61
89
|
if (injectEntry) {
|
|
62
90
|
injects.push(typeof injectEntry === "string" ? injectEntry : 'import "uno.css"');
|
|
@@ -66,6 +94,7 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
66
94
|
updateConfig({
|
|
67
95
|
vite: {
|
|
68
96
|
plugins: [AstroVitePlugin({
|
|
97
|
+
injectReset: !!injectReset,
|
|
69
98
|
injects
|
|
70
99
|
}), ...VitePlugin__default(options, defaults)]
|
|
71
100
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -4,31 +4,59 @@ import VitePlugin from '@unocss/vite';
|
|
|
4
4
|
|
|
5
5
|
const UNO_INJECT_ID = "uno-astro";
|
|
6
6
|
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
7
|
+
const astroCSSKeyRE = /(\?|\&)lang\.css/;
|
|
7
8
|
function AstroVitePlugin(options) {
|
|
8
|
-
const { injects } = options;
|
|
9
|
-
|
|
9
|
+
const { injects, injectReset } = options;
|
|
10
|
+
const resetInjectPath = injectReset ? injects[0] : void 0;
|
|
11
|
+
let command;
|
|
12
|
+
let nodeModulesPath;
|
|
13
|
+
let resetCSSInjected = false;
|
|
14
|
+
const resolveCSSQueue = /* @__PURE__ */ new Set();
|
|
10
15
|
return {
|
|
11
16
|
name: "unocss:astro",
|
|
12
17
|
enforce: "pre",
|
|
13
|
-
configResolved(
|
|
14
|
-
|
|
18
|
+
configResolved(config) {
|
|
19
|
+
command = config.command;
|
|
20
|
+
nodeModulesPath = `${config.root}/node_modules`;
|
|
15
21
|
},
|
|
16
22
|
async resolveId(id, importer) {
|
|
17
|
-
if (id === UNO_INJECT_ID)
|
|
23
|
+
if (id === UNO_INJECT_ID) {
|
|
24
|
+
if (injectReset) {
|
|
25
|
+
resetCSSInjected = false;
|
|
26
|
+
}
|
|
18
27
|
return id;
|
|
19
|
-
|
|
28
|
+
}
|
|
29
|
+
if (injectReset && command === "serve" && astroCSSKeyRE.test(id) && !resetCSSInjected)
|
|
30
|
+
return new Promise((resolve2) => resolveCSSQueue.add(() => resolve2()));
|
|
31
|
+
if (importer?.endsWith(UNO_INJECT_ID) && command === "serve") {
|
|
20
32
|
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
21
33
|
if (resolved) {
|
|
22
34
|
const fsPath = resolved.id;
|
|
23
|
-
|
|
35
|
+
const realId = `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
36
|
+
if (injectReset) {
|
|
37
|
+
if (resetInjectPath.includes(id)) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
resolveCSSQueue.forEach((res) => {
|
|
40
|
+
res();
|
|
41
|
+
resolveCSSQueue.delete(res);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
resetCSSInjected = true;
|
|
45
|
+
} else if (id.includes(".css") && !resetCSSInjected) {
|
|
46
|
+
return new Promise((resolve2) => {
|
|
47
|
+
resolveCSSQueue.add(() => resolve2(realId));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return realId;
|
|
24
52
|
}
|
|
25
53
|
}
|
|
26
54
|
},
|
|
27
55
|
load(id, options2) {
|
|
28
56
|
if (id.endsWith(UNO_INJECT_ID))
|
|
29
57
|
return injects.join("\n");
|
|
30
|
-
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css"))
|
|
31
|
-
return
|
|
58
|
+
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css") && !id.startsWith(nodeModulesPath))
|
|
59
|
+
return "";
|
|
32
60
|
}
|
|
33
61
|
};
|
|
34
62
|
}
|
|
@@ -50,7 +78,7 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
50
78
|
const injects = [];
|
|
51
79
|
if (injectReset) {
|
|
52
80
|
const resetPath = typeof injectReset === "string" ? injectReset : "@unocss/reset/tailwind.css";
|
|
53
|
-
injects.push(`import
|
|
81
|
+
injects.push(`import ${JSON.stringify(resetPath)}`);
|
|
54
82
|
}
|
|
55
83
|
if (injectEntry) {
|
|
56
84
|
injects.push(typeof injectEntry === "string" ? injectEntry : 'import "uno.css"');
|
|
@@ -60,6 +88,7 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
60
88
|
updateConfig({
|
|
61
89
|
vite: {
|
|
62
90
|
plugins: [AstroVitePlugin({
|
|
91
|
+
injectReset: !!injectReset,
|
|
63
92
|
injects
|
|
64
93
|
}), ...VitePlugin(options, defaults)]
|
|
65
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/astro",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.3",
|
|
4
4
|
"description": "UnoCSS integration for Astro",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@unocss/core": "0.53.
|
|
41
|
-
"@unocss/reset": "0.53.
|
|
42
|
-
"@unocss/vite": "0.53.
|
|
40
|
+
"@unocss/core": "0.53.3",
|
|
41
|
+
"@unocss/reset": "0.53.3",
|
|
42
|
+
"@unocss/vite": "0.53.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"astro": "^2.
|
|
45
|
+
"astro": "^2.7.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "unbuild",
|