diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..06cb150 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ + +[target.wasm32-unknown-unknown] +runner = "wasm-server-runner" +rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""] diff --git a/Cargo.toml b/Cargo.toml index ec3e807..9e49dc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,9 @@ rand = "0.9.2" rand_chacha = "0.9.0" [features] -dynamic_linking = ["bevy/dynamic_linking"] \ No newline at end of file +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"] }