building examples now uses a wasm binary size optimized release build

This commit is contained in:
Maccesch 2023-06-26 13:08:51 +01:00
parent 8e60515c40
commit 1abff6a4f2
4 changed files with 24 additions and 3 deletions

View file

@ -19,7 +19,7 @@ def build_and_copy_demo(category, md_name):
name = md_name[:-3]
example_dir = f"../../examples/{name}"
if os.path.exists(example_dir):
p = subprocess.Popen(["trunk", "build"], cwd=example_dir)
p = subprocess.Popen(["trunk", "build", "--release"], cwd=example_dir)
p.wait()
example_output_path = os.path.join(example_dir, "dist")

View file

@ -1,2 +1,6 @@
[build]
rustflags = ["--cfg=web_sys_unstable_apis"]
rustflags = ["--cfg=web_sys_unstable_apis", "--cfg=has_std"]
[unstable]
build-std = ["std", "panic_abort", "core", "alloc"]
build-std-features = ["panic_immediate_abort"]

View file

@ -32,3 +32,19 @@ members = [
"watch_pausable",
"watch_throttled",
]
[package]
name = "leptos-use-examples"
version = "0.3.3"
edition = "2021"
[profile.release]
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"
[lib]
[package.metadata.leptos]
lib-profile-release = "wasm-release"

1
examples/src/lib.rs Normal file
View file

@ -0,0 +1 @@
// necessary to be able to specify a release profile in the workspace root Cargo.toml