Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compiler-sfc): transform use href add no-inline query #12550

Closed
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function render(_ctx, _cache) {

exports[`compiler sfc: transform asset url > support uri fragment 1`] = `
"import { createElementVNode as _createElementVNode, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
import _imports_0 from '@svg/file.svg'
import _imports_0 from '@svg/file.svg?no-inline'


const _hoisted_1 = _imports_0 + '#fragment'
Expand Down
7 changes: 7 additions & 0 deletions packages/compiler-sfc/src/template/transformAssetUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ export const transformAssetUrl: NodeTransform = (
}

const url = parseUrl(attr.value.content)
if (
node.tag === 'use' &&
attr.name === 'href' &&
url.path?.endsWith('.svg')
) {
url.path = url.path + '?no-inline'
}
if (options.base && attr.value.content[0] === '.') {
// explicit base - directly rewrite relative urls into absolute url
// to avoid generating extra imports
Expand Down
Loading