Skip to content

Commit

Permalink
fix: public files map will be updated on add/unlink in windows (#15317)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlee2k authored Dec 11, 2023
1 parent 1597170 commit 921ca41
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,18 @@ export async function _createServer(
}
}

const normalizedPublicDir = normalizePath(config.publicDir)

const onFileAddUnlink = async (file: string, isUnlink: boolean) => {
file = normalizePath(file)
await container.watchChange(file, { event: isUnlink ? 'delete' : 'create' })

if (publicFiles && config.publicDir && file.startsWith(config.publicDir)) {
publicFiles[isUnlink ? 'delete' : 'add'](
file.slice(config.publicDir.length),
)
if (config.publicDir && publicFiles) {
if (file.startsWith(normalizedPublicDir)) {
publicFiles[isUnlink ? 'delete' : 'add'](
file.slice(normalizedPublicDir.length),
)
}
}
await handleFileAddUnlink(file, server, isUnlink)
await onHMRUpdate(file, true)
Expand Down

0 comments on commit 921ca41

Please sign in to comment.