Replies: 1 comment 1 reply
-
I've had luck with this approach in Svelte. I usually have a component where this lives in the module context. I pass a prop into the component to access the image from the object. Images are compiled at run and build time const pictures = import.meta.glob('$lib/assets/graphics/*.{jpg,jpeg,png}', {
query: { format: 'webp;avif;jpg', width: '200;400;600;1200', picture: '' },
import: 'default',
eager: true
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using
vite-imagetools
to optimize image assets at build time.imagetools
uses URL query syntax in the import path to declare transforms:Is there a way how I can combine this with
import.meta.glob
/import.meta.globEager
? Alternatively, is there another plugin that supports this?import.meta.globEager('path/to/images/*.jpg?width=500&webp');
as
-parameter is appended to the import path. When I use theas
-parameter in the import URL, the glob will match but the transforms will not be applied:import.meta.globEager('path/to/images/*.jpg', { as: 'width=500&webp' });
Beta Was this translation helpful? Give feedback.
All reactions