Use wasm-opt when compiling for web

This commit is contained in:
Emil Ernerfeldt 2021-04-01 23:07:43 +02:00
parent fe0d31204e
commit facb01a7c2
2 changed files with 7 additions and 2 deletions

View file

@ -22,3 +22,5 @@ egui_web = { path = 'egui_web' }
# opt-level = 1 # very slow and big wasm. Don't do this. # opt-level = 1 # very slow and big wasm. Don't do this.
opt-level = 2 # fast and small wasm, basically same as `opt-level = 's'` opt-level = 2 # fast and small wasm, basically same as `opt-level = 's'`
# opt-level = 3 # unecessarily large wasm for no performance gain # opt-level = 3 # unecessarily large wasm for no performance gain
# debug = true # include debug symbols, useful when profiling wasm

View file

@ -30,8 +30,11 @@ wasm-bindgen "target/wasm32-unknown-unknown/$BUILD/$TARGET_NAME" \
--out-dir docs --no-modules --no-typescript --out-dir docs --no-modules --no-typescript
# brew install wabt # to get wasm-strip # brew install wabt # to get wasm-strip
wasm-strip docs/${CRATE_NAME}_bg.wasm # wasm-strip docs/${CRATE_NAME}_bg.wasm
echo "Finished: docs/${CRATE_NAME}_bg.wasm" echo "Optimizing wasm…"
# brew install binaryen # to get wasm-opt
wasm-opt docs/egui_demo_app_bg.wasm -O2 --fast-math -o docs/egui_demo_app_bg.wasm # add -g to get debug symbols
echo "Finished docs/${CRATE_NAME}_bg.wasm"
open http://localhost:8888/index.html open http://localhost:8888/index.html