Skip to content

Commit 921ca41

Browse files
authored
fix: public files map will be updated on add/unlink in windows (#15317)
1 parent 1597170 commit 921ca41

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/vite/src/node/server/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,18 @@ export async function _createServer(
641641
}
642642
}
643643

644+
const normalizedPublicDir = normalizePath(config.publicDir)
645+
644646
const onFileAddUnlink = async (file: string, isUnlink: boolean) => {
645647
file = normalizePath(file)
646648
await container.watchChange(file, { event: isUnlink ? 'delete' : 'create' })
647649

648-
if (publicFiles && config.publicDir && file.startsWith(config.publicDir)) {
649-
publicFiles[isUnlink ? 'delete' : 'add'](
650-
file.slice(config.publicDir.length),
651-
)
650+
if (config.publicDir && publicFiles) {
651+
if (file.startsWith(normalizedPublicDir)) {
652+
publicFiles[isUnlink ? 'delete' : 'add'](
653+
file.slice(normalizedPublicDir.length),
654+
)
655+
}
652656
}
653657
await handleFileAddUnlink(file, server, isUnlink)
654658
await onHMRUpdate(file, true)

0 commit comments

Comments
 (0)