Trunk builds and bundles Rust WASM apps for the web from a source HTML entry. It includes a dev server, file watching, and asset pipeline support.
Overview
Trunk is a bundler aimed at Rust programs compiled to WebAssembly and delivered in the browser. It drives builds from a root HTML file and pulls together WASM output, JavaScript glue, and static assets such as images, CSS, and SCSS.
Configuration is optional and kept simple: you point Trunk at your HTML entry and it orchestrates compilation and bundling. The tool integrates with wasm-bindgen-style workflows and can compile SCSS through dart-sass when referenced from HTML.
For day-to-day work, Trunk ships a built-in development server with HTTP and WebSocket proxy support. It watches the project for changes, rebuilds when files change, and can trigger automatic browser reload during development.
Production output lands in a distributable folder with hashed asset names, ready to be served as static web content. Frameworks built on wasm-bindgen, such as Yew or Leptos, are commonly used alongside Trunk.
You install Trunk as a command-line tool, for example via released binaries or cargo install.
Key features
- HTML-driven WASM and asset bundling
- Built-in development HTTP server
- HTTP and WebSocket proxies
- Watch mode with automatic rebuilds
- Browser reload on change
- SCSS compilation via dart-sass
- Optional configuration pattern
- cargo install distribution
Use cases
- Shipping Rust WASM apps to the web
- Local WASM frontend development
- Bundling JS snippets with WASM output
- Serving SCSS and static assets with WASM
- Projects using wasm-bindgen frameworks