Expand description
cargo xtask run-wasm: build and serve the web examples.
The pipeline is the standard one for a wasm32-unknown-unknown binary a
browser runs: build for the target, hand the wasm to wasm-bindgen so it
gets a JS loader, then put the pages and the wasm behind a static file
server β WebGPU is only available in a secure context, and localhost
is one, while a file:// URL is not. The server is built in
(super::http), so nothing needs to be installed.
The output directory is the one the Pages workflow publishes: a landing
page at the root, one directory per example beside it, and the API docs
under docs/ β which only the workflow builds. --app picks which
examples are built; the landing page links the ones that are there.
Re-exportsΒ§
use std::path::Path;πuse std::path::PathBuf;πuse super::RunWasmArgs;πuse super::WebApp;πuse super::http;πuse super::step;π
StructsΒ§
- Example
- One example the site can show.
ConstantsΒ§
- DOCS_
DIR π - Where the API docs sit under the siteβs root.
- EXAMPLES
- Every example the site can show, in the order the landing page lists them.
- EXAMPLE_
HTML π - The page that starts one example.
- LANDING_
HTML π - The siteβs landing page: what the examples are, and where the docs are.
- OUT_DIR
- Where the bindgen output lands, inside
target/. - PORT π
- The port the site prefers to be served on. Fixed, so the URL to open is predictable; if it is taken, the server tries the ports after it.
- PROFILE
- The cargo profile every wasm build of this repository uses, defined in the
workspace manifest: releaseβs settings at a size-oriented
opt-level, the trade-off the name keeps from thewasm-devit was renamed from β wasm builds are only ever made for a browser to download, so none of them pay for the larger binary--releaseproduces. - TARGET
- The target triple the web build runs on.
FunctionsΒ§
- build
- Build the selected examples and the landing page into one directory.
- build_
example - Compile one example for
wasm32-unknown-unknown, and bindgen it. - example_
page π - The page that starts one example.
- examples π
- The examples
appasks for. - landing_
page π - The landing page: a link to each example that was built, and the API docs.
- run
- Build and serve the web site.