Skip to content

Instantly share code, notes, and snippets.

View mkxto's full-sized avatar
👋

tim mkxto

👋
View GitHub Profile
@mkxto
mkxto / import_folders_images-vitejs.jsx
Created February 24, 2023 17:47
Import all image from a folder with Vite, this version work in both dev and "release" mode.
Object.values(import.meta.glob('../path/*.{png,jpg,jpeg,PNG,JPEG}', { eager: true, as: 'url' }))
/*
Example:
[
0: "/src/assets/asso/Nogent_Seine.jpeg"
1: "/src/assets/asso/NogentsurSeine(2).jpeg"
2: "/src/assets/asso/Rimaucourt(2).jpg"
3: "/src/assets/asso/Rimaucourt(3).jpg"
4: "/src/assets/asso/Rimaucourt(4).jpg"