Skip to content

Commit

Permalink
chore(vite): improve module timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 5, 2022
1 parent 6d8d75b commit b7d48a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/vite-vue3/src/App.vue
@@ -1,7 +1,7 @@
<template>
<div text-center font-sans p4>
<div logo />
<div text-green5>
<div text-green5 text-lg>
Hello UnoCSS + Vue
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/modes/global/dev.ts
Expand Up @@ -16,6 +16,7 @@ export function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate

let invalidateTimer: any
const lastServedHash = new Map<string, string>()
let lastServedTime = Date.now()
let resolved = false
let resolvedWarnTimer: any

Expand Down Expand Up @@ -55,7 +56,7 @@ export function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate
return <Update>{
acceptedPath: mod.url,
path: mod.url,
timestamp: Date.now(),
timestamp: lastServedTime,
type: 'js-update',
}
})
Expand Down Expand Up @@ -137,6 +138,7 @@ export function GlobalModeDevPlugin({ uno, tokens, affectedModules, onInvalidate
: result.getLayer(layer)
const hash = getHash(css || '', HASH_LENGTH)
lastServedHash.set(layer, hash)
lastServedTime = Date.now()
// add hash to the chunk of CSS that it will send back to client to check if there is new CSS generated
return `/*${hash}*/${css}`
},
Expand Down

0 comments on commit b7d48a5

Please sign in to comment.