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: public files map will be updated on add/unlink in windows #15317

Merged
merged 2 commits into from Dec 11, 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
12 changes: 8 additions & 4 deletions packages/vite/src/node/server/index.ts
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