@unocss/vite
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1417,3 +1417,3 @@ var __create = Object.create; | ||
var import_pluginutils2 = __toModule(require("@rollup/pluginutils")); | ||
var VIRTUAL_ENTRY = "/@unocss-entry"; | ||
var VIRTUAL_ENTRY = "/@unocss-entry.css"; | ||
var READY_CALLBACK = "/__unocss_ready"; | ||
@@ -1449,2 +1449,3 @@ function GlobalModeDevPlugin({ config, uno, tokens, onInvalidate, scan }) { | ||
onInvalidate(invalidate); | ||
let mainEntry; | ||
return { | ||
@@ -1458,11 +1459,3 @@ name: "unocss:global", | ||
if (req.url === READY_CALLBACK) { | ||
let body = ""; | ||
await new Promise((resolve) => { | ||
req.on("data", (chunk) => { | ||
body += chunk; | ||
}); | ||
req.on("end", resolve); | ||
}); | ||
if (+body !== lastUpdate) | ||
sendUpdate(); | ||
sendUpdate(); | ||
res.statusCode = 200; | ||
@@ -1475,6 +1468,14 @@ res.end(); | ||
}, | ||
transform(code, id) { | ||
if (!filter(id)) | ||
return; | ||
scan(code, id); | ||
transform(code, id, context) { | ||
const isSSR = context === true || (context == null ? void 0 : context.ssr) === true; | ||
if (filter(id)) | ||
scan(code, id); | ||
if (!isSSR && (mainEntry == null || mainEntry === id) && !id.includes("node_modules/vite")) { | ||
mainEntry = id; | ||
code = ` | ||
await import("${VIRTUAL_ENTRY}").then(() => fetch('${READY_CALLBACK}')); | ||
${code} | ||
`; | ||
return code; | ||
} | ||
return null; | ||
@@ -1485,4 +1486,3 @@ }, | ||
}, | ||
async load(id, context) { | ||
const isSSR = context === true || (context == null ? void 0 : context.ssr) === true; | ||
async load(id) { | ||
if (id !== VIRTUAL_ENTRY) | ||
@@ -1492,25 +1492,3 @@ return null; | ||
const { css } = await uno.generate(tokens); | ||
if (isSSR) { | ||
return `export default ${JSON.stringify(`/* unocss */ | ||
${css}`)}`; | ||
} else { | ||
return ` | ||
import { updateStyle, removeStyle } from "/@vite/client"; | ||
const id = "${VIRTUAL_ENTRY}" | ||
import.meta.hot.accept() | ||
import.meta.hot.prune(() => removeStyle(id)) | ||
const css = ${JSON.stringify(`/* unocss */ | ||
${css}`)} | ||
updateStyle(id, css) | ||
export default css | ||
fetch('${READY_CALLBACK}', { method: 'POST', body: '${lastUpdate}' }) | ||
`; | ||
} | ||
}, | ||
transformIndexHtml: { | ||
enforce: "pre", | ||
async transform(code, { path }) { | ||
tasks.push(scan(code, path)); | ||
return `${code}<script src="${VIRTUAL_ENTRY}" type="module"><\/script>`; | ||
} | ||
return css; | ||
} | ||
@@ -1517,0 +1495,0 @@ }; |
{ | ||
"name": "@unocss/vite", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "", | ||
@@ -32,5 +32,5 @@ "keywords": [], | ||
"@rollup/pluginutils": "^4.1.1", | ||
"@unocss/config": "0.1.2", | ||
"@unocss/core": "0.1.2", | ||
"@unocss/scope": "0.1.2", | ||
"@unocss/config": "0.1.3", | ||
"@unocss/core": "0.1.3", | ||
"@unocss/scope": "0.1.3", | ||
"nanoevents": "^6.0.2" | ||
@@ -37,0 +37,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97851
3352
+ Added@unocss/config@0.1.3(transitive)
+ Added@unocss/core@0.1.3(transitive)
+ Added@unocss/scope@0.1.3(transitive)
- Removed@unocss/config@0.1.2(transitive)
- Removed@unocss/core@0.1.2(transitive)
- Removed@unocss/scope@0.1.2(transitive)
Updated@unocss/config@0.1.3
Updated@unocss/core@0.1.3
Updated@unocss/scope@0.1.3