Wasm template for Rust hosting without npm-deploy on github pages using Travis script
Last updated: 10th-March-2023
It automatically hosts you wasm projects on gh-pages using a travis script on the latest commit.
Requirements
Steps :
For building :
- Download the template as it is
- Change
Cargo.toml
to suit yourself - Change
www/package.json
to 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 build
inside your project dictionary - Run
npm install
insidewww
folder - Next, modify
www/index.js
to import yourPROJECT
instead of thewasm-template-rust
package - Again run
npm install
insidewww
folder (just to be sure) - Finally run
npm run start
insidewww
and visit http://localhost:8080 to see the results
For deployment :
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 Pages
and enable it on yourgh-pages
branch. 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 Variables
and enter the tokenvalue
(the generated token code) andname
asGITHUB_TOKEN
, it should look like :
Additional :
- 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
License
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)