-
I have a "gallery" of images which gets loaded like so:
Is it possible to have the plugin process the images that get imported in this way? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
ElMassimo
Mar 29, 2023
Replies: 1 comment 3 replies
-
In Vite 2 there was no way to pass "parameters" to glob imports. However, in Vite 4, it's now possible to use import type { ImageAttrs } from 'vite-plugin-image-presets'
const images = import.meta.glob<ImageAttrs[]>("@/assets/images/**", {
eager: true,
as: "preset=default", // use whatever preset you want
import: 'default', // to simplify "unwrapping" the imports
}) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ElMassimo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Vite 2 there was no way to pass "parameters" to glob imports.
However, in Vite 4, it's now possible to use
as
to provide the parameters, and this works as expected: