Skip to content

Latest commit

History

History
60 lines (48 loc) 路 3.79 KB

README.md

File metadata and controls

60 lines (48 loc) 路 3.79 KB

Wasm template for Rust hosting without npm-deploy on github pages using Travis script

Featured on This Week in Rust 327

Last updated: 29th-September-2023

Build Status

It automatically hosts you wasm projects on gh-pages using a travis script on the latest commit.

Requirements

Steps :

For building :

  "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 inside www folder
  • Next, modify www/index.js to import your PROJECT instead of the wasm-template-rust package
  • Again run npm install inside www folder (just to be sure)
  • Finally run npm run start inside www 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 your gh-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 token value (the generated token code) and name as GITHUB_TOKEN, it should look like : token

Additional :

License

Licensed under either of these: