Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hmr): dynamic safelist cause Unlimited hot updates #3205

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/vite/src/modes/global/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ export function GlobalModeDevPlugin({ uno, tokens, tasks, flushTasks, affectedMo
async configureServer(_server) {
servers.push(_server)

_server.ws.on(WS_EVENT_PREFIX, async ([layer, hash]: string[]) => {
_server.ws.on(WS_EVENT_PREFIX, async ([layer]: string[]) => {
const preHash = lastServedHash.get(layer)
await generateCSS(layer)
if (lastServedHash.get(layer) !== hash)
if (lastServedHash.get(layer) !== preHash)
sendUpdate(entries)
})
},
Expand Down Expand Up @@ -180,7 +181,7 @@ try {
if (!hash)
console.warn('[unocss-hmr]', 'failed to get unocss hash, hmr might not work')
else
await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}', hash]);
await import.meta.hot.send('${WS_EVENT_PREFIX}', ['${layer}']);
} catch (e) {
console.warn('[unocss-hmr]', e)
}
Expand Down