This commit is contained in:
Emil Ernerfeldt 2022-08-19 17:41:46 +02:00
parent d12c19da37
commit 08b025b4e4
8 changed files with 21 additions and 19 deletions

View file

@ -1,12 +1,12 @@
name: Github Pages
# By default, runs if you push to master. keeps your deployed app in sync with master branch.
# By default, runs if you push to master. keeps your deployed app in sync with master branch.
on:
push:
branches:
- master
# to only run when you do a new github release, comment out above part and uncomment the below trigger.
# on:
# on:
# release:
# types:
# - published
@ -27,7 +27,7 @@ jobs:
override: true
- name: Rust Cache # cache the rust build artefacts
uses: Swatinem/rust-cache@v1
- name: Downlaod and Install Trunk binary
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build # build
# "${GITHUB_REPOSITORY#*/}" evaluates into the name of the repository
@ -35,7 +35,7 @@ jobs:
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested
# relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which
# will obviously return error 404 not found.
run: ./trunk build --release --public-url "${GITHUB_REPOSITORY#*/}"
run: ./trunk build --release --public-url "${GITHUB_REPOSITORY#*/}"
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:

View file

@ -99,7 +99,7 @@ jobs:
toolchain: 1.61.0
target: wasm32-unknown-unknown
override: true
- name: Downlaod and Install Trunk binary
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build
run: ./trunk build
- name: Build
run: ./trunk build

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
/target
/dist
/dist

View file

@ -47,11 +47,11 @@ On Fedora Rawhide you need to run:
### Web Locally
You can compile your app to [WASM](https://en.wikipedia.org/wiki/WebAssembly) and publish it as a web page.
You can compile your app to [WASM](https://en.wikipedia.org/wiki/WebAssembly) and publish it as a web page.
We use [Trunk](https://trunkrs.dev/) to build for web target.
1. Install Trunk with `cargo install --locked trunk`.
2. run `trunk serve` to build and serve on `http://127.0.0.1:8080`. will rebuild automatically if you edit the project.
1. Install Trunk with `cargo install --locked trunk`.
2. run `trunk serve` to build and serve on `http://127.0.0.1:8080`. will rebuild automatically if you edit the project.
3. open `http://127.0.0.1:8080/index.html#dev` in a browser. see the warning below.
> `assets/sw.js` script will try to cache our app, and loads the cached version when it cannot connect to server allowing your app to work offline (like PWA).
@ -61,10 +61,10 @@ We use [Trunk](https://trunkrs.dev/) to build for web target.
1. Just run `trunk build --release`.
2. It will generate a `dist` directory as a "static html" website
3. Upload the `dist` directory to any of the numerous free hosting websites including [GitHub Pages](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).
4. we already provide a workflow that auto-deploys our app to github pages if you enable it.
> To enable Github Pages, you need to go to Respository -> Settings -> Pages -> Source -> set to `gh-pages` branch and `/` (root).
>
> If `gh-pages` is not availabe in `Source`, just create and push a branch called `gh-pages` and it should be available.
4. we already provide a workflow that auto-deploys our app to GitHub pages if you enable it.
> To enable Github Pages, you need to go to Repository -> Settings -> Pages -> Source -> set to `gh-pages` branch and `/` (root).
>
> If `gh-pages` is not available in `Source`, just create and push a branch called `gh-pages` and it should be available.
You can test the template app at <https://emilk.github.io/eframe_template/>.

View file

@ -1,5 +1,5 @@
{
"name": "Egui Template PWA",
"name": "egui Template PWA",
"short_name": "egui-template-pwa",
"icons": [
{
@ -25,4 +25,4 @@
"display": "standalone",
"background_color": "white",
"theme_color": "white"
}
}

View file

@ -22,4 +22,4 @@ self.addEventListener('fetch', function (e) {
return response || fetch(e.request);
})
);
});
});

View file

@ -8,3 +8,4 @@ cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
cargo test --workspace --all-targets --all-features
cargo test --workspace --doc
trunk build

View file

@ -112,6 +112,7 @@
transform: rotate(360deg);
}
}
</style>
</head>
@ -134,4 +135,4 @@
</html>
<!-- Powered by egui: https://github.com/emilk/egui/ -->
<!-- Powered by egui: https://github.com/emilk/egui/ -->