custom_assets.rs 448 B

1234567891011121314151617181920
  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 = manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif));
  6. fn main() {
  7. launch(app);
  8. }
  9. fn app() -> Element {
  10. rsx! {
  11. div {
  12. p { "This should show an image:" }
  13. img { src: ASSET_PATH.to_string() }
  14. }
  15. }
  16. }