Created
April 4, 2024 11:56
-
-
Save awwsmm/0c98f4c1bfe88ffcf6b33b4c3ad28fd0 to your computer and use it in GitHub Desktop.
Bash script to compile Rust code to WASM and generate JavaScript bindings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# $1: package name from Cargo.toml | |
# run with e.g.: bash build-and-bind.sh flappy-bevy | |
# build | |
rustup target add wasm32-unknown-unknown | |
cargo build --release --target wasm32-unknown-unknown | |
# bind | |
cargo install -q wasm-bindgen-cli | |
wasm-bindgen --out-dir target --target web target/wasm32-unknown-unknown/release/"$1".wasm | |
# ...and then run with live-server | |
cargo install live-server | |
live-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment