Open frederikheld opened 1 year ago
looking at the source it does not support optimizing the ?url
import, because there's a built-in ?url
handler: https://vitejs.dev/guide/assets.html#explicit-url-imports
but since we are handling the import before that, we can probably simply url encode it ourselves and not rely on vite's functionality, this should be easy I guess. but it will be a breaking change, because it can potentially break it for anyone who is relying on it, what do you think @cpsoinos ? should we release it as a breaking change or as minor if we are going to do so ?
I'll work on it when I have time, not sure if I can do this week
Thanks for considering adding this feature :-)
Maybe keep the current behavior as default and add a config option that allows to run url imports through svgo optimization? This would avoid the breaking change ...
hmm, good idea, thanks!
.... simply url encode it ourselves ...
I was really tired and I see that I misunderstood the feature lol
what ?url
does is that it gives the url for that file, not url encode it (what I originally thought it was)
I have to rethink how to do it, and how feasible it is
I guess I would be happy with the url encoded version as well, if it can be used as a favicon ...
sorry, I didn't have access to my laptop for around 1.5 weeks I'll get to it soon
url encoded version probably can be done quite easily, but not sure about how the direct url to optimized file works, so will put that for a later time
I have released the url_encode
query feature @frederikheld
let me know if there's any issue
I have updated the readme to include a note about it as well
@frederikheld did you manage to test it ?
I've seen that you implemented it, thanks a lot, that's awesome. However I did not find the time to test it as I have to take care of a different project atm. As soon as i get back to this project, I'll let you know if something doesn't work as expected :-) Thanks again for providing a solution so quickly!
The
nuxt-svgo
docs don't mention this feature, but thevite-svg-loader
docs do: it is possible to import a svg as a file url (instead of embedding it into the source of the page) and it works withnuxt-svgo
as well. I use this feature to generate an optimized version of the svg to use it as favicon.Unfortunately this option seems to bypass the optimization through
svgo
. The default import embeds an optimized version of the svg into the source code, but the url import generates a file that is exactly the same as the asset that went in. Is this on purpose? Is there any way to have the optimization with the url import? Unfortunately thevite-svg-loader
docs only mention that it is possible, but neither how it works inside nor how it can be configured...I fiddled around with the
svgoConfig
option ofnuxt-svgo
but couldn't find any working configuration. Any ideas?