mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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) {
|
function resolveFromPublicAssets (id: string) {
|
||||||
for (const dir of nitro.options.publicAssets) {
|
for (const dir of nitro.options.publicAssets) {
|
||||||
if (!id.startsWith(withTrailingSlash(dir.baseURL || '/'))) { continue }
|
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)) {
|
if (existsSync(path)) {
|
||||||
return id
|
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>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<img src="/public.svg">
|
<img src="/public.svg">
|
||||||
|
<img src="/public.svg?123">
|
||||||
<img src="/custom/file.svg">
|
<img src="/custom/file.svg">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user