Building rust for web with WASM
One of the goals for this project is to produce runnable example in the web browser using web assembly. So let’s dive in to that.
Building
Luckily, our graphics library macroquad has comes with WASM build support. The documentation lists the following commands to build for WASM:
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown
Running them goes smoothly and produces a .wasm file. I’ve copied that over into the project for this blog, inserted a bit of html, and:
Voila!!! We can now put running examples straight into the blog!