mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
fix(vite): ignore query/hash when resolving public assets (#27306)
This commit is contained in:
parent
eb0bebc46d
commit
305c7348bd
@ -12,7 +12,7 @@ export const VitePublicDirsPlugin = createUnplugin(() => {
|
||||
function resolveFromPublicAssets (id: string) {
|
||||
for (const dir of nitro.options.publicAssets) {
|
||||
if (!id.startsWith(withTrailingSlash(dir.baseURL || '/'))) { continue }
|
||||
const path = id.replace(withTrailingSlash(dir.baseURL || '/'), withTrailingSlash(dir.dir))
|
||||
const path = id.replace(/[?#].*$/, '').replace(withTrailingSlash(dir.baseURL || '/'), withTrailingSlash(dir.dir))
|
||||
if (existsSync(path)) {
|
||||
return id
|
||||
}
|
||||
|
1
test/fixtures/basic/pages/assets-custom.vue
vendored
1
test/fixtures/basic/pages/assets-custom.vue
vendored
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<img src="/public.svg">
|
||||
<img src="/public.svg?123">
|
||||
<img src="/custom/file.svg">
|
||||
</div>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user