transformAssetUrls
strips all queries and breaks SVG sprites
#490
Labels
bug
Something isn't working
p3-minor-bug 🔨
An edge case that only affects very specific usage (priority)
Describe the bug
I updated one of my work projects to Vite 6 and all the images in SVG tags disappeared. If I move Vite back to 5.4.9 or later, which is where I was prior to updating my project, the SVGs come back.
Reproduction
https://github.com/dirkniblick/vite-6-breaks-svg
Steps to reproduce
Here's a reproduction of the repo README:
Project
I created a project using
npm create vue@latest
and removed most of the default project files (i.e., very little is left in/src
). At this point, it just displays a couple SVGs. Here's the most relevant files:src/vite.config.js
👈 Unchanged from when project was createdsrc/assets/shapes.svg
src/App.vue
Expectation
With Vite 5.4.11 we get this in Firefox (I've tested all this in Chrome too):
The developer tools shows this:
Problem
If I change Vite to 6.0.0, or anything later, and don't change anything else, the shapes disappear:
The developer tools shows this:
Comparison
It looks like Vite is not processing the file correctly.
If there's something I need to change in the Vite config, please let me know, but I haven't spotted anything specific to SVGs in the migration document or any other issue on Github. Here's the developer tools side-by-side, but you can see the
<use href=
is quite different and theuse
tag doesn't seem to contain the path code anymore.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: