Replies: 1 comment 2 replies
-
Rather than passing in the file to your You might be the be able to use it with something like https://github.com/bluwy/svelte-preprocess-import-assets to let you use basically just the file path when consuming. I've been wanting to try that in my own project, but haven't had a chance yet |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Objective
I want to create a reusable component to generate optimized images that accepts two props
file
andalt
that would look like this in use:<Picture file="svelte.png" alt="svelte" />
It would output html picture like this:
The Issue
Now, I know it's possible to generate webp images using
vite-imagetools
. But I don't see a way to make a dynamic import with it inside my<Picture />
component using thefile
prop passed from the parent. So something like this doesn't work:Is it even possible? Or what's the best way to create something like this?
Beta Was this translation helpful? Give feedback.
All reactions