eframe_template icon indicating copy to clipboard operation
eframe_template copied to clipboard

Add `trunk` template alongside current template for web

Open yusdacra opened this issue 2 years ago • 5 comments

trunk (https://trunkrs.dev/) is a complete build driver for wasm / web. It is very easy to use and has good defaults, and can easily be configured. I believe instead of using bash scripts and whatnot, it would be better to use trunk so that it's simpler to deploy and work with.

My suggestion would be to keep the scripts, but add a separate branch (or folder?) showing how it looks with trunk. Essentially it's just a simple index.html file at the root of the repository (which trunk uses to configure the build with), as seen like here.

yusdacra avatar Jan 16 '22 12:01 yusdacra

That sounds like a good idea! Would you like to contribute it?

emilk avatar Jan 17 '22 18:01 emilk

Sure! I can go with the branch approach and link that in the README.md, which should be okay I think.

yusdacra avatar Jan 17 '22 19:01 yusdacra

I think a separate folder is better first step (easier to keep up-to-date). If it works well, we can maybe switch it to be the default :)

emilk avatar Jan 19 '22 12:01 emilk

so, i tried doing this https://github.com/coderedart/eframe_template .

it was pretty easy to do.

most of the work is in https://github.com/coderedart/eframe_template/commit/b25fc179130da765e6cdee8f2bc29bd219e33373 commit. just needed to add the copy commands, comment out the custom wasm_bindgen stuff from index.html, add the start function to main.rs and finally set the favicon (in another commit).

I added a separate pages.yml to automate the publishing to github pages part.

  1. I set the tags as the trigger, but personally, i would just use the push as trigger to keep the live version up to date with the master branch. i will leave this decision to you on what triggers to use.
  2. I use a separate branch for the live build instead of building and committing the latest live build in docs/ folder. I felt there's no point in actually committing the temporary builds of js / wasm to git history of the source repo itself.
  3. live build link: https://coderedart.github.io/eframe_template/
  4. I also use rust-cache action to cache the rust artefacts. when you are often just fixing tiny little things in commits, there's no point in recompiling from scratch :)
  5. the most important part is that even if it is not used, i think providing a commented out version will be useful for people who want to use this. this workflow stuff (especially with wasm) is not easy to setup. speaking as a newbie that had to mess around for an hour to figure out that i needed to use --public-url option with github repo name or trunk can't set the relative paths right

anyway, i accidentally clicked use template button instead of fork, so i will need to make a new PR anyway. just wanted to know if any changes are required before i start the PR (or if anyone else wants to take this and add more stuff).

coderedart avatar Jul 17 '22 17:07 coderedart

forgot to mention that trunk uses /dist folder and not docs by default to build the website and i added it to .gitignore as that's what most people would do.

EDIT: even if the workflow runs, you must also go to github repo -> settings -> pages -> source -> set to branch : gh-pages + /(root) as source and click on save. only after that will pages-build-deployment action will run (everytime there's a push to gh-pages by our pages.yaml workflow) and deploy the latest files to servers.

coderedart avatar Jul 17 '22 17:07 coderedart