Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/assetImportMetaUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
isDataUrl,
isParentDirectory,
transformStableResult,
tryStatSync,
} from '../utils'
import { CLIENT_ENTRY } from '../constants'
import { slash } from '../../shared/utils'
Expand Down Expand Up @@ -142,8 +143,11 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
const publicPath = '/' + path.posix.relative(publicDir, file)
builtUrl = await fileToUrl(this, publicPath)
} else {
this.addWatchFile(file)
builtUrl = await fileToUrl(this, file)
// during dev, builtUrl may point to a directory or a non-existing file
if (tryStatSync(file)?.isFile()) {
this.addWatchFile(file)
}
}
} catch {
// do nothing, we'll log a warning after this
Expand Down
Loading