@unocss/vite 0.49.5 → 0.49.6

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 CHANGED
@@ -644,7 +644,7 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
644
644
  if (!layer)
645
645
  return null;
646
646
  const { hash, css } = await generateCSS(layer);
647
- return `/*${hash}*/${css}`;
647
+ return `__uno_hash_${hash}{--:''};${css}`;
648
648
  }
649
649
  },
650
650
  {
@@ -659,7 +659,12 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
659
659
  if (layer && code.includes("import.meta.hot")) {
660
660
  let hmr = `
661
661
  try {
662
- await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}', __vite__css.slice(2,${2 + HASH_LENGTH})]);
662
+ let hash = __vite__css.match(/__uno_hash_(\\w{${HASH_LENGTH}})/)
663
+ hash = hash && hash[1]
664
+ if (!hash)
665
+ console.warn('[unocss-hmr]', 'failed to get unocss hash, hmr might not work')
666
+ else
667
+ await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}', hash]);
663
668
  } catch (e) {
664
669
  console.warn('[unocss-hmr]', e)
665
670
  }
package/dist/index.mjs CHANGED
@@ -631,7 +631,7 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
631
631
  if (!layer)
632
632
  return null;
633
633
  const { hash, css } = await generateCSS(layer);
634
- return `/*${hash}*/${css}`;
634
+ return `__uno_hash_${hash}{--:''};${css}`;
635
635
  }
636
636
  },
637
637
  {
@@ -646,7 +646,12 @@ function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedModules,
646
646
  if (layer && code.includes("import.meta.hot")) {
647
647
  let hmr = `
648
648
  try {
649
- await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}', __vite__css.slice(2,${2 + HASH_LENGTH})]);
649
+ let hash = __vite__css.match(/__uno_hash_(\\w{${HASH_LENGTH}})/)
650
+ hash = hash && hash[1]
651
+ if (!hash)
652
+ console.warn('[unocss-hmr]', 'failed to get unocss hash, hmr might not work')
653
+ else
654
+ await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}', hash]);
650
655
  } catch (e) {
651
656
  console.warn('[unocss-hmr]', e)
652
657
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
- "version": "0.49.5",
3
+ "version": "0.49.6",
4
4
  "description": "The Vite plugin for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -44,17 +44,17 @@
44
44
  "dependencies": {
45
45
  "@ampproject/remapping": "^2.2.0",
46
46
  "@rollup/pluginutils": "^5.0.2",
47
- "@unocss/config": "0.49.5",
48
- "@unocss/core": "0.49.5",
49
- "@unocss/inspector": "0.49.5",
50
- "@unocss/scope": "0.49.5",
51
- "@unocss/transformer-directives": "0.49.5",
47
+ "@unocss/config": "0.49.6",
48
+ "@unocss/core": "0.49.6",
49
+ "@unocss/inspector": "0.49.6",
50
+ "@unocss/scope": "0.49.6",
51
+ "@unocss/transformer-directives": "0.49.6",
52
52
  "chokidar": "^3.5.3",
53
53
  "fast-glob": "^3.2.12",
54
54
  "magic-string": "^0.29.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@unocss/shared-integration": "0.49.5",
57
+ "@unocss/shared-integration": "0.49.6",
58
58
  "vite": "^4.1.1"
59
59
  },
60
60
  "scripts": {