Open rparrett opened 2 years ago
In my project, I made a .justfile with something like this:
default: run
build-wasm:
cargo build --release --target wasm32-unknown-unknown --no-default-features
wasm-bindgen --no-typescript --out-name bevy_game --out-dir wasm --target web target/wasm32-unknown-unknown/release/my_game.wasm
cp -r assets wasm/
run: build-wasm
sfz ./wasm
It runs the same commands as in CI, and I can do $ just run
to build for WASM and start local server
That's great info to collect here.
I've been using cargo make
in mine (example) to do something similar. It's sort of nice because you can write the tasks in cross-platform "duckscript." and it has some built-ins for ensuring crates like wasm-bindgen
and a local dev server are installed.
We could also recommend wasm-server-runner
, but I'm not a fan of that here because it uses its own separate index.html and there's no way to change that as far as I can tell.
I think the main reason this hasn't been done in-repo is that there are a lot of options.
To throw another option into the room, bevy_quickstart is using trunk
. We're pretty happy with it, but it comes with the caveat that it does not accept any custom profiles.
It would be great to have some instructions or scripts or something for users to easily do local testing/development for the web.
There are a bunch of ways to break a web build and the feedback loop could be substantially shortened.