- Rust toolchain (rustup, rustc, cargo)
- wasm-pack
- Run
cargo install cargo-generateto get cargo-generate - npm
- Use the following template
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name rust-connect-four cd rust-connect-four- Run
wasm-pack buildto build the project. This should generate pkg directory - Run
npm init wasm-app www - Go into the www directory and run
npm installso all initial dependencies are installed - Add the following code into package.json file:
"dependencies": {
"wasm-connect-four": "file:../pkg"
}- Modify www/index.js change "hello-wasm-pack" to "wasm-connect-four"
- Within www directory
npm install
npm run start
- Go to localhost:8080 in any browser to see the alert message appear
When the server is running (after running npm run start):
- Updates to www will appear automatically
- Updates to rust files in src appear after running
wasm-pack buildwithout taking down server
If there are issues with www being recognized as a submodule after running step 4 (or in general), see this link