mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
c6a2e5b6c8
* use head elements and new manganis syntax in examples * only enable desktop workspace example scraping during a dioxus release --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
27 lines
843 B
Rust
27 lines
843 B
Rust
//! A simple example on how to use assets loading from the filesystem.
|
|
//!
|
|
//! If the feature "collect-assets" is enabled, the assets will be collected via the dioxus CLI and embedded into the
|
|
//! final bundle. This lets you do various useful things like minify, compress, and optimize your assets.
|
|
//!
|
|
//! We can still use assets without the CLI middleware, but generally larger apps will benefit from it.
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
#[cfg(not(feature = "collect-assets"))]
|
|
static ASSET_PATH: &str = "examples/assets/logo.png";
|
|
|
|
#[cfg(feature = "collect-assets")]
|
|
static ASSET_PATH: &str = asset!("examples/assets/logo.png".format(ImageType::Avif));
|
|
|
|
fn main() {
|
|
launch(app);
|
|
}
|
|
|
|
fn app() -> Element {
|
|
rsx! {
|
|
div {
|
|
h1 { "This should show an image:" }
|
|
img { src: ASSET_PATH.to_string() }
|
|
}
|
|
}
|
|
}
|