A controlled Ubuntu environment (Docker) for compiling Rust in to WebAssembly.
docker build -t ubuntu-wasm docker/In your host machine, run the Docker container.
docker run -it -v $PWD/:/var/workspace -p 8081:8081 ubuntu-wasm /bin/bash(Mounts the present working directory to /var/workspace/ and runs bash.)
Compile Rust code within the Docker container:
rustc +nightly --target wasm32-unknown-unknown -O \
--crate-type=cdylib src/main.rs \
-o build/main.big.wasm
wasm-gc build/main.big.wasm build/main.wasmThe Docker container runs a local HTTP server to host the local contents,
docker run -p 8081:8081 -v $PWD/:/var/workspace ubuntu-wasmIn a browser, http://localhost:8081.