@unocss/vite 0.50.2 → 0.50.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 CHANGED
@@ -948,14 +948,15 @@ async function transformSvelteSFC(code, id, uno, options = {}) {
948
948
  processedMap.add(start);
949
949
  s.overwrite(start, start + match[1].length, `${className}={${token}}`);
950
950
  }
951
- const { matched } = await uno.generate(code, { preflights: false, safelist: false, minify: true });
951
+ const templateCode = code.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1\s*>/g, (match) => Array(match.length).fill(" ").join(""));
952
+ const { matched } = await uno.generate(templateCode, { preflights: false, safelist: false, minify: true });
952
953
  for (const token of matched) {
953
954
  const match = token.match(core.attributifyRE);
954
955
  if (match) {
955
956
  const [, name, value] = match;
956
957
  if (!value) {
957
958
  let start = 0;
958
- code.split(/([\s"'`;*]|:\(|\)"|\)\s)/g).forEach((i) => {
959
+ templateCode.split(/([\s"'`;*]|:\(|\)"|\)\s)/g).forEach((i) => {
959
960
  const end = start + i.length;
960
961
  if (i === name && !processedMap.has(start)) {
961
962
  const className = queueCompiledClass([name]);
@@ -966,7 +967,7 @@ async function transformSvelteSFC(code, id, uno, options = {}) {
966
967
  });
967
968
  } else {
968
969
  const regex = new RegExp(`(${core.escapeRegExp(name)}=)(['"])[^\\2]*?${core.escapeRegExp(value)}[^\\2]*?\\2`, "g");
969
- for (const match2 of code.matchAll(regex)) {
970
+ for (const match2 of templateCode.matchAll(regex)) {
970
971
  const escaped = match2[1];
971
972
  const body = match2[0].slice(escaped.length);
972
973
  let bodyIndex = body.match(`[\\b\\s'"]${core.escapeRegExp(value)}[\\b\\s'"]`)?.index ?? -1;
package/dist/index.mjs CHANGED
@@ -935,14 +935,15 @@ async function transformSvelteSFC(code, id, uno, options = {}) {
935
935
  processedMap.add(start);
936
936
  s.overwrite(start, start + match[1].length, `${className}={${token}}`);
937
937
  }
938
- const { matched } = await uno.generate(code, { preflights: false, safelist: false, minify: true });
938
+ const templateCode = code.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1\s*>/g, (match) => Array(match.length).fill(" ").join(""));
939
+ const { matched } = await uno.generate(templateCode, { preflights: false, safelist: false, minify: true });
939
940
  for (const token of matched) {
940
941
  const match = token.match(attributifyRE);
941
942
  if (match) {
942
943
  const [, name, value] = match;
943
944
  if (!value) {
944
945
  let start = 0;
945
- code.split(/([\s"'`;*]|:\(|\)"|\)\s)/g).forEach((i) => {
946
+ templateCode.split(/([\s"'`;*]|:\(|\)"|\)\s)/g).forEach((i) => {
946
947
  const end = start + i.length;
947
948
  if (i === name && !processedMap.has(start)) {
948
949
  const className = queueCompiledClass([name]);
@@ -953,7 +954,7 @@ async function transformSvelteSFC(code, id, uno, options = {}) {
953
954
  });
954
955
  } else {
955
956
  const regex = new RegExp(`(${escapeRegExp(name)}=)(['"])[^\\2]*?${escapeRegExp(value)}[^\\2]*?\\2`, "g");
956
- for (const match2 of code.matchAll(regex)) {
957
+ for (const match2 of templateCode.matchAll(regex)) {
957
958
  const escaped = match2[1];
958
959
  const body = match2[0].slice(escaped.length);
959
960
  let bodyIndex = body.match(`[\\b\\s'"]${escapeRegExp(value)}[\\b\\s'"]`)?.index ?? -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/vite",
3
- "version": "0.50.2",
3
+ "version": "0.50.3",
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.50.2",
48
- "@unocss/core": "0.50.2",
49
- "@unocss/inspector": "0.50.2",
50
- "@unocss/scope": "0.50.2",
51
- "@unocss/transformer-directives": "0.50.2",
47
+ "@unocss/config": "0.50.3",
48
+ "@unocss/core": "0.50.3",
49
+ "@unocss/inspector": "0.50.3",
50
+ "@unocss/scope": "0.50.3",
51
+ "@unocss/transformer-directives": "0.50.3",
52
52
  "chokidar": "^3.5.3",
53
53
  "fast-glob": "^3.2.12",
54
54
  "magic-string": "^0.30.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@unocss/shared-integration": "0.50.2",
57
+ "@unocss/shared-integration": "0.50.3",
58
58
  "vite": "^4.1.4"
59
59
  },
60
60
  "scripts": {