@unocss/astro 66.5.9 → 66.5.10

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.
Files changed (2) hide show
  1. package/dist/index.mjs +13 -5
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -3,19 +3,24 @@ import { fileURLToPath } from 'node:url';
3
3
  import VitePlugin from '@unocss/vite';
4
4
  import { normalizePath } from 'vite';
5
5
 
6
- const RESOLVED_ID_RE = /[/\\]__uno(?:_(.*?))?\.css$/;
7
-
8
6
  const UNO_INJECT_ID = "uno-astro";
9
7
  function AstroVitePlugin(options) {
10
8
  const { injects } = options;
11
9
  let root;
10
+ let ctx;
12
11
  return {
13
12
  name: "unocss:astro",
14
13
  enforce: "pre",
15
14
  configResolved(config) {
16
15
  root = config.root;
16
+ const api = config.plugins.find((i) => i.name === "unocss:api")?.api;
17
+ if (!api) {
18
+ throw new Error("[@unocss/astro] Unable to find UnoCSS Vite plugin API.");
19
+ }
20
+ ctx = api.getContext();
17
21
  },
18
22
  async resolveId(id, importer) {
23
+ const { RESOLVED_ID_RE } = await ctx.getVMPRegexes();
19
24
  if (RESOLVED_ID_RE.test(id)) {
20
25
  return this.resolve(normalizePath(join(root, id)), importer, { skipSelf: true });
21
26
  }
@@ -54,9 +59,12 @@ function UnoCSSAstroIntegration(options = {}, defaults) {
54
59
  injects.push(...injectExtra);
55
60
  updateConfig({
56
61
  vite: {
57
- plugins: [AstroVitePlugin({
58
- injects
59
- }), ...VitePlugin(options, defaults)]
62
+ plugins: [
63
+ AstroVitePlugin({
64
+ injects
65
+ }),
66
+ ...VitePlugin(options, defaults)
67
+ ]
60
68
  }
61
69
  });
62
70
  if (injects?.length)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/astro",
3
3
  "type": "module",
4
- "version": "66.5.9",
4
+ "version": "66.5.10",
5
5
  "description": "UnoCSS integration for Astro",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -45,9 +45,9 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@unocss/vite": "66.5.9",
49
- "@unocss/reset": "66.5.9",
50
- "@unocss/core": "66.5.9"
48
+ "@unocss/core": "66.5.10",
49
+ "@unocss/reset": "66.5.10",
50
+ "@unocss/vite": "66.5.10"
51
51
  },
52
52
  "devDependencies": {
53
53
  "astro": "^4.16.19"