Using theRust and WebAssembly Working Group'swasm-pack
crate, which lets you compile rust code into WASM, and provides an interface with JavaScript.
📖 Project built from thisMozilla Developer Documentation Tutorial
- Clone the Repo:
git clone https://github /jwhogg/rust-wasm-boilerplate
- Build for web using a bundler:
in the main dir:
wasm-pack build --target bundler
- Install webpack:
npm i -D webpack@5 webpack-cli@5 webpack-dev-server@4 copy-webpack-plugin@11
- Serve the site:
cd site
npm run serve
- All done! Navigate to
http://localhost:8080
,and you should see a pop-up:Hello, WebAssembly with npm!