Add WASM-specific configurations

I've added a runner override to use the wasm-server-runner for easy
devlopment -- it's a localhost webserver to provide the WASM binary &
it's bootstrap code.

There is also target-specific config related to the RNG back-end.
This commit is contained in:
2025-09-07 16:50:19 -05:00
parent a4064ed124
commit fbcc16bc22
2 changed files with 10 additions and 1 deletions

4
.cargo/config.toml Normal file
View File

@@ -0,0 +1,4 @@
[target.wasm32-unknown-unknown]
runner = "wasm-server-runner"
rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""]

View File

@@ -10,3 +10,8 @@ rand_chacha = "0.9.0"
[features] [features]
dynamic_linking = ["bevy/dynamic_linking"] dynamic_linking = ["bevy/dynamic_linking"]
# For WASM builds, we need to use the browser's RNG back-end.
# This also requires the extra rustflags in `.cargo/config.toml`
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.3.3", features = ["wasm_js"] }