#[run_example]
Expand description
This macro helps to run an example in the project’s examples/
directory using a development
server.
§Usage
-
In the file
examples/my_example.rs
, create your example:ⓘuse wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] fn log(message: &str); } #[xtask_wasm::run_example] fn run_app() { log::("Hello World!"); }
-
In the project’s
Cargo.toml
:[dev-dependencies] xtask-wasm = { version = "*", features = ["run-example"] }
-
Then to run the development server with the example:
cargo run --example my_example
§Arguments
You can give arguments to the macro to customize the example:
app_name
- Change the app name.index
- Content of a customindex.html
.static_dir
- Path to a custom static directory.