Load folder as asset / make 800+ images availiable on frontend only? #3672
-
Hey, Is there a way to load a folder of asset images without 800 lines of asset macros? I am still fairly new to Rust and developement in general (1st year university student), so I apologize in advance for anything I did wrong so far. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Yes, you can include a whole folder with the asset macro like this: let folder = asset!("path/to/local/folder");
let file = format!("{folder}/file/within/folder.png"); |
Beta Was this translation helpful? Give feedback.
-
Folder assets are great! Please add to the guide. This took forever to figure out (I am visually impaired, using AI to search the dioxus code, docs, etc. and still couldn't figure out.) This is fantastic: const WORKERS: Asset = asset!("/assets/workers"); ✅ Folder name hashed:
✅ Filenames within folder not hashed (excellent!):
This is exactly what we want, especially with WASM worker/JS loader pairs, because Yes, please add this to the Guide! |
Beta Was this translation helpful? Give feedback.
Yes, you can include a whole folder with the asset macro like this: