custom_assets.rs 459 B

123456789101112131415161718192021
  1. use dioxus::prelude::*;
  2. #[cfg(not(feature = "collect-assets"))]
  3. static ASSET_PATH: &str = "examples/assets/logo.png";
  4. #[cfg(feature = "collect-assets")]
  5. static ASSET_PATH: &str =
  6. manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif)).path();
  7. fn main() {
  8. launch(app);
  9. }
  10. fn app() -> Element {
  11. rsx! {
  12. div {
  13. p { "This should show an image:" }
  14. img { src: ASSET_PATH.to_string() }
  15. }
  16. }
  17. }