A simple frontend in Rust🦀️ for a goban (go game board).
cargo install trunk wasm-bindgen-cli
- Trunk is really amazing. At the time of writing it is recommended only in the non-stable version of the yew documentation. Trunk mentions that in the future, the
wasm-bindgen-clipackage will be installed as part of trunk.
rustup target add wasm32-unknown-unknown
- Otherwise
trunk buildwon't go through.
trunk build
- This creates the
/distfolder. Under the hood it also runscargo buildthat creates the/targetfolder. So you can still normally use cargo's check, build or clippy for checking code. -
The folder
/staticand its contents are copied via trunk automatically to/distthanks to this line inindex.html:
"<link data-trunk rel="copy-dir" href="static"/>"
trunk serve
-
To cut the total size, get a clean output folder (if previous builds were made). This deletes the
./distfolder.trunk clean -
Make a new optimized build.
trunk build --release
If you want to run the html directly, for example on a different system, just launching index.html from ./dist/ won't work! If you need to use the index.html directly (for example in a link on your web), you have to change the 3 addresses for the .css, .js and .wasm inside. Otherwise by default it is searching for them in root.
But locally the simplest way is to serve the folder:
- take the content of
./dist/and serve it with any of these:-
rust tool:
miniserve ./dist --index index.html -
npm (nodejs) tool:
http-server ./dist -
usually present by default on linux (run from inside the folder):
python3 -m http.server
-
