Web Deployment
This document describes the first-class web target flow:
morph build --target=webmorph run --target=web
Prerequisites
- Emscripten toolchain must be installed and active in the shell.
em++must be resolvable fromPATH(or by the toolchain resolver).- Build host must be able to run the normal
morphCLI.
Configuration (morph.toml)
Web target behavior is controlled by the [web] section:
[web]
canvas_id = "morph-canvas"
wgsl_cache = true
dev_server_port = 8080
enable_shared_array = true
initial_memory_mb = 64
maximum_memory_mb = 512
wasm_simd = true
Key notes:
canvas_id: canvas element id used by loader glue.wgsl_cache: enables build-time SPIR-V to WGSL cache reuse.dev_server_port: port used bymorph run --target=web.enable_shared_array: enables pthread/shared-array linker flags.initial_memory_mb/maximum_memory_mb: wasm memory bounds.wasm_simd: enables wasm SIMD (+simd128,-msimd128).
Build Flow
morph build --target=web performs:
- Compiles the project entry into a wasm object (
wasm32-unknown-emscripten). - Transpiles discovered
.spvshaders to WGSL (AOT) with cache support. - Links runtime + program with
em++into web artifacts. - Generates web entry files from templates.
Default output directory:
build/web/index.htmlbuild/web/loader.jsbuild/web/app.jsbuild/web/app.wasmbuild/web/shaders/*.wgsl(when shader inputs exist)
Run Flow
morph run --target=web:
- Triggers the web build pipeline.
- Starts embedded zero-dependency dev server.
- Serves
build/weband opens browser (unless--no-openis passed).
The dev server always returns required isolation headers:
Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corpCross-Origin-Resource-Policy: same-origin
This is required for SharedArrayBuffer-enabled thin-client scenarios.