Featured on This Week in Rust 327
Last updated: 29th-September-2023
It automatically hosts you wasm projects on gh-pages using a travis script on the latest commit.
- Download the template as it is
- Change
Cargo.tomlto suit yourself - Change
www/package.jsonto suit yourself, also remember to change
"dependencies": {
"wasm-template-rust": "file:../pkg"
},Into :
"dependencies": {
"YOUR-PROJECT-NAME-SAME-AS-IN-CARGO.toml": "file:../pkg"
},- Run
wasm-pack buildinside your project dictionary - Run
npm installinsidewwwfolder - Next, modify
www/index.jsto import yourPROJECTinstead of thewasm-template-rustpackage - Again run
npm installinsidewwwfolder (just to be sure) - Finally run
npm run startinsidewwwand visit http://localhost:8080 to see the results
The template comes with a preconfigured .travis.yml but you will still need to :
- Create a new branch by the name
gh-pages - Github pages should be enabled by default but if not go to
Settings -> GitHub Pagesand enable it on yourgh-pagesbranch. You will also find the link to your to-be hosted page there - Make a personal access token (only the token no need for command line here)
- Next we will need to put this token into our travis settings, go to
more options -> settings -> Environment Variablesand enter the tokenvalue(the generated token code) andnameasGITHUB_TOKEN, it should look like :
- Update LICENSE-MIT and LICENSE-APACHE to reflect your name and year
- Read Rust and WebAssembly
- Also read wasm-pack
- Also see wasm-conway made using Rust 🦀 and WebAssembly 🕸 hosted at gh-pages
Licensed under either of these:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)