In my vue-cli project, I need to reference an svg-file in an <img>
-tag. That works.
Now inside this svg file, I have an <image xlink:href="...">
– And this path is not touched or resolved by webpack.
Example:
<!-- MyComponent.vue -->
<img src="@/assets/someImage.svg" />
<!-- someImage.svg -->
<svg ...>
<!-- none of these are working -->
<image ... xlink:href="@/assets/arcade-bg-4.jpg"/>
<image ... xlink:href="~@/assets/arcade-bg-4.jpg"/>
<image ... xlink:href="./assets/arcade-bg-4.jpg"/>
<image ... xlink:href="/src/assets/arcade-bg-4.jpg"/>
</svg>
The question now is, how I can tell webpack to solve paths inside this svg file?
Possible workarounds:
* put arcade-bg-4.jpg
in /public
and reference this in the xlink:href
* use inline-<svg>
in MyComponent.vue
But I'd like to keep the <img />
-tag and also keep the file-hashing feature from vue-cli.
Background:
I use this setup to achieve a (relatively) cross-browser-ready clip-mask with a .jpg
instead of a .png
, which is way smaller and more performant.