diff --git a/justfile b/justfile index 0f7db68..e04864e 100644 --- a/justfile +++ b/justfile @@ -8,16 +8,19 @@ web GAME: # wasm binary cargo build --bin {{GAME}} --profile wasm-release --target wasm32-unknown-unknown - # Size pass - wasm-opt -Oz \ - -o dist/{{GAME}}.wasm \ - ${CARGO_TARGET_DIR}/wasm32-unknown-unknown/release/{{GAME}}.wasm - # wasm bindgen wasm-bindgen --no-typescript --target web \ --out-dir ./dist/{{GAME}} \ --out-name "bin" \ - dist/{{GAME}}.wasm + ${CARGO_TARGET_DIR}/wasm32-unknown-unknown/release/{{GAME}}.wasm + + # Size pass + wasm-opt -Oz \ + -o dist/{{GAME}}/bin_bg-tmp.wasm \ + ./dist/{{GAME}}/bin_bg.wasm + + # Replace old bin with new (compressed) bin + mv ./dist/{{GAME}}/bin_bg-tmp.wasm ./dist/{{GAME}}/bin_bg.wasm # index.html cp ./web/{{GAME}}.html ./dist/{{GAME}}/index.html diff --git a/src/bin/flappy/main.rs b/src/bin/flappy/main.rs index 811d0dd..38bb53c 100644 --- a/src/bin/flappy/main.rs +++ b/src/bin/flappy/main.rs @@ -566,14 +566,6 @@ fn init_ui(mut commands: Commands, server: Res) { ..default() },)) .with_children(|parent| { - fn quit_game( - _trigger: Trigger>, - mut exit: EventWriter, - ) { - warn!("Quitting game"); - exit.write(AppExit::Success); - } - fn show_credits( _trigger: Trigger>, mut state: ResMut>, @@ -590,15 +582,27 @@ fn init_ui(mut commands: Commands, server: Res) { children![(TextColor(BLACK.into()), Text::new("Credits")),], )) .observe(show_credits); - parent - .spawn(( - BorderRadius::all(Val::Px(5.0)), - BorderColor(BLACK.into()), - Button, - Node { ..default() }, - children![(Text::new("Quit"), TextColor(BLACK.into()))], - )) - .observe(quit_game); + + #[cfg(not(target_arch = "wasm32"))] + { + fn quit_game( + _trigger: Trigger>, + mut exit: EventWriter, + ) { + warn!("Quitting game"); + exit.write(AppExit::Success); + } + + parent + .spawn(( + BorderRadius::all(Val::Px(5.0)), + BorderColor(BLACK.into()), + Button, + Node { ..default() }, + children![(Text::new("Quit"), TextColor(BLACK.into()))], + )) + .observe(quit_game); + } }); });