mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(vite): don't terminate with escaped delimiters (#5409)
This commit is contained in:
parent
fbcbac01d6
commit
8831e4a4b9
@ -89,7 +89,7 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
|
||||
s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"')
|
||||
|
||||
// Dynamically compute string URLs featuring baseURL
|
||||
const delimiterRE = /(?<!(const base = |from *))(`([^`]*)\/__NUXT_BASE__\/([^`]*)`|'([^\n']*)\/__NUXT_BASE__\/([^\n']*)'|"([^\n"]*)\/__NUXT_BASE__\/([^\n"]*)")/g
|
||||
const delimiterRE = /(?<!(const base = |from *))((?<!\\)`([^`]*)\/__NUXT_BASE__\/([^`]*)(?<!\\)`|(?<!\\)'([^\n']*)\/__NUXT_BASE__\/([^\n']*)(?<!\\)'|(?<!\\)"([^\n"]*)\/__NUXT_BASE__\/([^\n"]*)(?<!\\)")/g
|
||||
/* eslint-disable-next-line no-template-curly-in-string */
|
||||
s.replace(delimiterRE, r => '`' + r.replace(/\/__NUXT_BASE__\//g, '${__publicAssetsURL()}').slice(1, -1) + '`')
|
||||
|
||||
|
@ -349,6 +349,8 @@ describe('dynamic paths', () => {
|
||||
[
|
||||
"./logo.svg",
|
||||
"../public.svg",
|
||||
"../public.svg",
|
||||
"../public.svg",
|
||||
]
|
||||
`)
|
||||
})
|
||||
|
6
test/fixtures/basic/pages/assets.vue
vendored
6
test/fixtures/basic/pages/assets.vue
vendored
@ -13,8 +13,14 @@ import logo from '~/assets/logo.svg'
|
||||
<style>
|
||||
#__nuxt {
|
||||
background-image: url('~/assets/logo.svg');
|
||||
@font-face {
|
||||
src: url("/public.svg") format("woff2");
|
||||
}
|
||||
}
|
||||
body {
|
||||
background-image: url('/public.svg');
|
||||
@font-face {
|
||||
src: url('/public.svg') format('woff2');
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user