diff --git a/crates/maelstrom-web/Cargo.toml b/crates/maelstrom-web/Cargo.toml index aa2940d2..15881445 100644 --- a/crates/maelstrom-web/Cargo.toml +++ b/crates/maelstrom-web/Cargo.toml @@ -45,3 +45,11 @@ cargo_metadata.workspace = true # These dependencies ensure the build script re-runs maelstrom-plot.workspace = true maelstrom-base.workspace = true + +# These profiles are copied from the workspace root so they can be used when +# publishing. See this issue +[profile.wasm_dev] +inherits = "dev" + +[profile.wasm_release] +inherits = "release" diff --git a/crates/maelstrom-web/build.rs b/crates/maelstrom-web/build.rs index 03638965..07ca02a1 100644 --- a/crates/maelstrom-web/build.rs +++ b/crates/maelstrom-web/build.rs @@ -1,5 +1,5 @@ use std::fs; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::Command; use wasm_bindgen_cli_support::Bindgen; @@ -123,11 +123,8 @@ fn create_web_tar(profile: &str, build_dir: &Path) { wasm_opt(&pkg_dir.join("maelstrom_web_bg.wasm")); } - create_tar( - Path::new("www"), - &pkg_dir, - &build_dir.join(profile).join("web.tar"), - ); + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + create_tar(Path::new("www"), &pkg_dir, &out_dir.join("web.tar")); } fn main() { diff --git a/crates/maelstrom-web/src/lib.rs b/crates/maelstrom-web/src/lib.rs index e868e1be..ffa0dde0 100644 --- a/crates/maelstrom-web/src/lib.rs +++ b/crates/maelstrom-web/src/lib.rs @@ -13,8 +13,5 @@ pub async fn start() -> Result<(), JsValue> { } } -#[cfg(all(not(target_arch = "wasm32"), not(debug_assertions)))] -pub const WASM_TAR: &[u8] = include_bytes!("../../../target/wasm_release/web.tar"); - -#[cfg(all(not(target_arch = "wasm32"), debug_assertions))] -pub const WASM_TAR: &[u8] = include_bytes!("../../../target/wasm_dev/web.tar"); +#[cfg(not(target_arch = "wasm32"))] +pub const WASM_TAR: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/web.tar"));