-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Resolve/load url()
references in CSS
#14686
Comments
I suppose this is related to #10555. There's a perf concern if we run all Vite plugins for CSS resolving. |
Would be nice to solve this issue, to allow images optimization also in css |
Ran into this issue as well. I found that I can run my
I was wrong about the above too, |
@lilnasy Is this workaround applicable for plugins like vite-imagetools? |
@lilnasy could you show a hint where to dig to implement the custom resolver? |
Yes, although the plugin currently depends on the "load" hook. Within CSS, I think only the "resolve" could logically work. For example, it can resolve
I implemented a font loader for my project using this customResolver: plugin code, usage. Plugin authors might find the internal rollup plugin's source code helpful: rollup/plugins alias(). I'm not sure why its "resolve" hook gets called but third party plugins' doesn't. I'm guessing one of the plugins in this plugin chain blocks it: vitejs/vite resolvePlugins() |
Description
vite-imagetools
transforms images to more efficient file formats. This works great for images included via animport
in the JS. However, Vite'surl()
references are only being half handled today. Vite's static asset handling does rename these assets to have a hash in their name. But thevite-imagetools
plugin is never invoked, so we can't do think like change jpg/png images to webp.Suggested solution
Invoke Vite plugins on asset URLs found in CSS just as is done for asset URLs found in JS
Alternative
No response
Additional context
This is one of the top feature requests in
vite-imagetools
: JonasKruckenberg/imagetools#563Validations
The text was updated successfully, but these errors were encountered: