mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
fix(compiler-sfc): should transform non relative paths when base option is present
fix https://github.com/vitejs/vite-plugin-vue2/issues/14
This commit is contained in:
parent
bf64c4da5c
commit
008d78bd72
@ -31,7 +31,6 @@ export function urlToRequire(
|
||||
uriParts.path + (uriParts.hash || '')
|
||||
)}"`
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -207,6 +207,7 @@ test('transform assetUrls and srcset with base option', () => {
|
||||
<img src="~fixtures/logo.png">
|
||||
<img src="~/fixtures/logo.png">
|
||||
<img src="./logo.png" srcset="./logo.png 2x, ./logo.png 3x">
|
||||
<img src="@/fixtures/logo.png">
|
||||
</div>
|
||||
`
|
||||
const result = compileTemplate({
|
||||
@ -218,13 +219,16 @@ test('transform assetUrls and srcset with base option', () => {
|
||||
|
||||
expect(result.errors.length).toBe(0)
|
||||
|
||||
const vnode = mockRender(result.code)
|
||||
const vnode = mockRender(result.code, {
|
||||
'@/fixtures/logo.png': 'aliased'
|
||||
})
|
||||
expect(vnode.children[0].data.attrs.src).toBe('/base/logo.png')
|
||||
expect(vnode.children[2].data.attrs.src).toBe('/base/fixtures/logo.png')
|
||||
expect(vnode.children[4].data.attrs.src).toBe('/base/fixtures/logo.png')
|
||||
expect(vnode.children[6].data.attrs.srcset).toBe(
|
||||
'/base/logo.png 2x, /base/logo.png 3x'
|
||||
)
|
||||
expect(vnode.children[8].data.attrs.src).toBe('aliased')
|
||||
})
|
||||
|
||||
test('transform with includeAbsolute', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user