Skip to content

Commit

Permalink
fix(hmr): dynamic safelist cause unlimited hot updates (#3205)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Oct 23, 2023
1 parent 3c65363 commit 9bbb27c
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 9bbb27c

Please sign in to comment.