Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Friendship with wasmpack ended, trunk is my new best friend #197

Merged
merged 2 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/mipsy_web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
dist/
static/wasm.js
static/tailwind.css
static/wasm_bg.wasm
tailwind.css
Session.vim
_static/tailwind.css
19 changes: 6 additions & 13 deletions crates/mipsy_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,12 @@ See [mipsy](https://github.com/insou22/mipsy/blob/main/README.md) for more infor
## Dependencies
1) Install rust via rustup, by following the instructions at [rustup](https://www.rust-lang.org/tools/install)
2) Install tailwindcss via npm `npm i -g tailwindcss`.
3) Install cargo-watch using `cargo install cargo-watch` if you wish to serve with hot-reload.
3) Install trunk via the instructions on [their website](https://trunkrs.dev/)

## Development
1) `scripts/build_dev.sh` will compile the relevant rust code to wasm files, and place into the static directory
2) `scripts/serve.sh` will simply run a http client inside `static/` to serve the relevant files.

`scripts/hot_reload_build.sh` also exists to compile the rust code to wasm files, but will also watch for changes to the `src` directory

## Production
1) `scripts/deploy.sh` will be useful for figuring out how to compile release, build tailwind for release, and then deploy.

## Debug
If you have no CSS - you will need to produce `tailwind.css` file , `./purge_tailwind.sh` should help here.

tailwind setup with https://dev.to/arctic_hen7/how-to-set-up-tailwind-css-with-yew-and-trunk-il9
1) `trunk serve` will compile the relevant rust code to wasm files, generate the css, chuck them into `dist/` and serve a web server.
It will also watch files for changes, and reload. You can use `trunk serve` during development
2) `trunk build --release` is used for deployment. It will compile optimized rust code, optimized/minified css + bundle them in `dist/`.

## Deployment
1) `scripts/deploy.sh` runs the build script, and then copies across the files to UNSW cse web servers.
16 changes: 16 additions & 0 deletions crates/mipsy_web/Trunk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[build]
# The index HTML file to drive the bundling process.
target = "index.html"
# Build in release mode.
release = false
# The output dir for all final assets.
dist = "dist"
# The public URL from which assets are to be served.
public_url = "/"
# Whether to include hash values in the output file names.
filehash = true

[[hooks]]
stage = "build"
command = "sh"
command_arguments = ["-c", "mkdir -p $TRUNK_STAGING_DIR/assets; if [ $TRUNK_PROFILE = 'release' ]; then NODE_ENV=production tailwindcss -c ./tailwind.config.js -o $TRUNK_STAGING_DIR/assets/tailwind.css --minify; else tailwindcss -c ./tailwind.config.js -o $TRUNK_STAGING_DIR/assets/tailwind.css; fi"]
192 changes: 0 additions & 192 deletions crates/mipsy_web/_static/index.html

This file was deleted.

Loading