@unocss/astro 0.51.13 → 0.52.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.cjs +40 -5
- package/dist/index.mjs +40 -5
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,36 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
const VitePlugin__default = /*#__PURE__*/_interopDefaultLegacy(VitePlugin);
|
|
10
10
|
|
|
11
|
+
const UNO_INJECT_ID = "uno-astro";
|
|
12
|
+
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
13
|
+
function AstroVitePlugin(options) {
|
|
14
|
+
const { injects } = options;
|
|
15
|
+
let config;
|
|
16
|
+
return {
|
|
17
|
+
name: "unocss:astro",
|
|
18
|
+
enforce: "pre",
|
|
19
|
+
configResolved(_config) {
|
|
20
|
+
config = _config;
|
|
21
|
+
},
|
|
22
|
+
async resolveId(id, importer) {
|
|
23
|
+
if (id === UNO_INJECT_ID)
|
|
24
|
+
return id;
|
|
25
|
+
if (importer?.endsWith(UNO_INJECT_ID) && config && config.command === "serve") {
|
|
26
|
+
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
27
|
+
if (resolved) {
|
|
28
|
+
const fsPath = resolved.id;
|
|
29
|
+
return `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
load(id, options2) {
|
|
34
|
+
if (id.endsWith(UNO_INJECT_ID))
|
|
35
|
+
return injects.join("\n");
|
|
36
|
+
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css"))
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
11
41
|
function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
12
42
|
const {
|
|
13
43
|
injectEntry = true,
|
|
@@ -17,13 +47,11 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
17
47
|
return {
|
|
18
48
|
name: "unocss",
|
|
19
49
|
hooks: {
|
|
20
|
-
"astro:config:setup": async ({ config, injectScript }) => {
|
|
21
|
-
var _a
|
|
50
|
+
"astro:config:setup": async ({ config, updateConfig, injectScript }) => {
|
|
51
|
+
var _a;
|
|
22
52
|
options.extraContent || (options.extraContent = {});
|
|
23
53
|
(_a = options.extraContent).filesystem || (_a.filesystem = []);
|
|
24
54
|
options.extraContent.filesystem.push(node_path.resolve(node_url.fileURLToPath(config.srcDir), "components/**/*").replace(/\\/g, "/"));
|
|
25
|
-
(_b = config.vite).plugins || (_b.plugins = []);
|
|
26
|
-
config.vite.plugins.push(...VitePlugin__default(options, defaults));
|
|
27
55
|
const injects = [];
|
|
28
56
|
if (injectReset) {
|
|
29
57
|
const resetPath = typeof injectReset === "string" ? injectReset : "@unocss/reset/tailwind.css";
|
|
@@ -34,8 +62,15 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
34
62
|
}
|
|
35
63
|
if (injectExtra.length > 0)
|
|
36
64
|
injects.push(...injectExtra);
|
|
65
|
+
updateConfig({
|
|
66
|
+
vite: {
|
|
67
|
+
plugins: [AstroVitePlugin({
|
|
68
|
+
injects
|
|
69
|
+
}), ...VitePlugin__default(options, defaults)]
|
|
70
|
+
}
|
|
71
|
+
});
|
|
37
72
|
if (injects?.length)
|
|
38
|
-
injectScript("page-ssr",
|
|
73
|
+
injectScript("page-ssr", `import ${JSON.stringify(UNO_INJECT_ID)}`);
|
|
39
74
|
}
|
|
40
75
|
}
|
|
41
76
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,36 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import VitePlugin from '@unocss/vite';
|
|
4
4
|
|
|
5
|
+
const UNO_INJECT_ID = "uno-astro";
|
|
6
|
+
const UNO_QUERY_KEY = "uno-with-astro-key";
|
|
7
|
+
function AstroVitePlugin(options) {
|
|
8
|
+
const { injects } = options;
|
|
9
|
+
let config;
|
|
10
|
+
return {
|
|
11
|
+
name: "unocss:astro",
|
|
12
|
+
enforce: "pre",
|
|
13
|
+
configResolved(_config) {
|
|
14
|
+
config = _config;
|
|
15
|
+
},
|
|
16
|
+
async resolveId(id, importer) {
|
|
17
|
+
if (id === UNO_INJECT_ID)
|
|
18
|
+
return id;
|
|
19
|
+
if (importer?.endsWith(UNO_INJECT_ID) && config && config.command === "serve") {
|
|
20
|
+
const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
21
|
+
if (resolved) {
|
|
22
|
+
const fsPath = resolved.id;
|
|
23
|
+
return `${fsPath}${fsPath.includes("?") ? "&" : "?"}${UNO_QUERY_KEY}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
load(id, options2) {
|
|
28
|
+
if (id.endsWith(UNO_INJECT_ID))
|
|
29
|
+
return injects.join("\n");
|
|
30
|
+
if (!options2?.ssr && id.includes(UNO_QUERY_KEY) && id.includes(".css"))
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
5
35
|
function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
6
36
|
const {
|
|
7
37
|
injectEntry = true,
|
|
@@ -11,13 +41,11 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
11
41
|
return {
|
|
12
42
|
name: "unocss",
|
|
13
43
|
hooks: {
|
|
14
|
-
"astro:config:setup": async ({ config, injectScript }) => {
|
|
15
|
-
var _a
|
|
44
|
+
"astro:config:setup": async ({ config, updateConfig, injectScript }) => {
|
|
45
|
+
var _a;
|
|
16
46
|
options.extraContent || (options.extraContent = {});
|
|
17
47
|
(_a = options.extraContent).filesystem || (_a.filesystem = []);
|
|
18
48
|
options.extraContent.filesystem.push(resolve(fileURLToPath(config.srcDir), "components/**/*").replace(/\\/g, "/"));
|
|
19
|
-
(_b = config.vite).plugins || (_b.plugins = []);
|
|
20
|
-
config.vite.plugins.push(...VitePlugin(options, defaults));
|
|
21
49
|
const injects = [];
|
|
22
50
|
if (injectReset) {
|
|
23
51
|
const resetPath = typeof injectReset === "string" ? injectReset : "@unocss/reset/tailwind.css";
|
|
@@ -28,8 +56,15 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
|
|
|
28
56
|
}
|
|
29
57
|
if (injectExtra.length > 0)
|
|
30
58
|
injects.push(...injectExtra);
|
|
59
|
+
updateConfig({
|
|
60
|
+
vite: {
|
|
61
|
+
plugins: [AstroVitePlugin({
|
|
62
|
+
injects
|
|
63
|
+
}), ...VitePlugin(options, defaults)]
|
|
64
|
+
}
|
|
65
|
+
});
|
|
31
66
|
if (injects?.length)
|
|
32
|
-
injectScript("page-ssr",
|
|
67
|
+
injectScript("page-ssr", `import ${JSON.stringify(UNO_INJECT_ID)}`);
|
|
33
68
|
}
|
|
34
69
|
}
|
|
35
70
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.1",
|
|
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.
|
|
41
|
-
"@unocss/
|
|
42
|
-
"@unocss/
|
|
40
|
+
"@unocss/core": "0.52.1",
|
|
41
|
+
"@unocss/reset": "0.52.1",
|
|
42
|
+
"@unocss/vite": "0.52.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"astro": "^2.
|
|
45
|
+
"astro": "^2.5.2"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "unbuild",
|