Trivially run wasm applications and examples in the browser
APACHE-2.0 License
Allows running wasm applications and examples as simply as:
cargo run-wasm --example example_name
or
cargo run-wasm --package crate_name
or
cargo run-wasm --bin bin_name
In the background it:
Cargo.toml
:
[package]
name = "run-wasm"
version = "0.1.0"
edition = "2021"
[dependencies]
cargo-run-wasm = "0.3.0"
main.rs
:
fn main() {
cargo_run_wasm::run_wasm_cli_with_css("body { margin: 0px; }");
}
.cargo/config
file containing:[alias]
run-wasm = "run --release --package run-wasm --"
cargo run-wasm --help
to view all the possible flags.Note: If you want to avoid restructuring your project into a proper workspace you can do so by combining your workspace and crate Cargo.toml
into a single file like winit does.
cargo update
updates both of them at the same time thanks to being in the same workspacecargo-run-wasm is not available as a cargo custom command as that would cause:
If you wish to set custom css, do so in the string argument to run_wasm_cli_with_css
.
However it is not possible to set custom html from cargo-run-wasm, instead any DOM elements you require should be created from within your crate or example using web-sys or another crate. The reasoning is that in the case an example requires custom HTML it will probably:
Since this tool has a trivial implementation the MSRV is at 1.70 and will only be increased if dependencies require it. If it is ever increased it must be below the MSRV of maintained branches of important users such as wgpu and winit.
The MSRV is enforced in CI and locally via the rust-toolchain.toml
file.
cargo install wasm-server-runner
Licensed under either of
at your option.