diff --git a/Cargo.toml b/Cargo.toml index 3f0c2ad..c314ed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ shared = { path = "./shared", version = "0.1.0" } # Enable a small amount of optimization in debug mode [profile.dev] -opt-level = 's' -strip = true +opt-level = 1 +# strip = true # Enable high optimizations for dependencies (incl. Bevy), but not for our code: [profile.dev.package."*"] @@ -17,4 +17,4 @@ opt-level = 3 [profile.release] lto = true opt-level = 's' -strip = true +# strip = true diff --git a/app/src/bin/client.rs b/app/src/hydrate.rs similarity index 97% rename from app/src/bin/client.rs rename to app/src/hydrate.rs index 6ff695f..ecd18f9 100644 --- a/app/src/bin/client.rs +++ b/app/src/hydrate.rs @@ -1,6 +1,6 @@ use std::io; -use app::app; +use crate::app; use leptos::{leptos_dom::logging::console_log, mount_to_body}; use wasm_bindgen::prelude::wasm_bindgen; diff --git a/app/src/lib.rs b/app/src/lib.rs index aefdf64..a17d696 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -18,6 +18,8 @@ pub mod adapters; pub mod extractors; #[cfg(feature = "ssr")] pub mod handlers; +#[cfg(feature = "hydrate")] +pub mod hydrate; #[cfg(feature = "ssr")] pub mod middleware; #[cfg(feature = "ssr")] diff --git a/flake.nix b/flake.nix index e622a50..bfd4fc8 100644 --- a/flake.nix +++ b/flake.nix @@ -42,13 +42,14 @@ cp -r assets/* site/ cp -r game/assets site/assets + cargo build --target wasm32-unknown-unknown --no-default-features --release -p app --lib --features app/hydrate,app/wasm + ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/app.wasm --no-typescript --remove-name-section --remove-producers-section --out-name index --target web --out-dir ./site/pkg + cargo build --target wasm32-unknown-unknown --no-default-features --release -p app --bin worker --features app/ssr,app/wasm - cargo build --target wasm32-unknown-unknown --no-default-features --release -p app --bin client --features app/hydrate,app/wasm - cargo build --target wasm32-unknown-unknown --no-default-features --release -p game --bin game --features game/wasm + ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/worker.wasm --no-typescript --remove-name-section --remove-producers-section --out-name index --target bundler --out-dir ./site - ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/worker.wasm --no-typescript --out-name index --target bundler --out-dir ./site - ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/client.wasm --no-typescript --out-name index --target web --out-dir ./site/pkg - ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/game.wasm --no-typescript --out-name game --target web --out-dir ./site/pkg + cargo build --target wasm32-unknown-unknown --no-default-features --release -p game --bin game --features game/wasm + ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen ./target/wasm32-unknown-unknown/release/game.wasm --no-typescript --remove-name-section --remove-producers-section --out-name game --target web --out-dir ./site/pkg ''; dev-clean = pkgs.writeShellScriptBin "dev-clean" '' @@ -75,9 +76,9 @@ set -o errexit set -o pipefail - CLIENT_TARGET="./target/wasm32-unknown-unknown/debug/client.wasm" + CLIENT_TARGET="./target/wasm32-unknown-unknown/debug/app.wasm" - cargo build --target wasm32-unknown-unknown --no-default-features -p app --bin client --features app/hydrate,app/wasm + cargo build --target wasm32-unknown-unknown --no-default-features -p app --lib --features app/hydrate,app/wasm ${pkgs.wasm-bindgen-cli}/bin/wasm-bindgen $CLIENT_TARGET --no-typescript --out-name index --target web --out-dir ./site/pkg echo "############### FINISHED BUILDING CLIENT ###############"