trunk.rs
TLDR
Build the application in release mode and serve it locally
Build the application and serve it on a specific port
Build for production at a specific output directory
Build with a specific public URL path for hosting in a subdirectory
Clean the output directory
SYNOPSIS
trunk <subcommand> [OPTIONS] [<INPUT>]
PARAMETERS
-h, --help
Prints help information
-V, --version
Prints version information
-d, --dist <DIR>
Output directory for build artifacts (default: dist)
-v, --verbose
Increase verbosity (repeat for more)
-q, --quiet
Decrease verbosity (repeat for less)
--release
Build in release mode (optimized)
--public-url <URL>
Base public URL for assets (default: /)
--hash
Hash asset filenames for cache busting
-w, --watch
Watch for changes and rebuild
DESCRIPTION
Trunk is a command-line tool designed for building, bundling, and deploying web applications written in Rust. It compiles Rust code to WebAssembly (WASM), bundles it with HTML, CSS, JavaScript, and assets into optimized outputs, and provides a fast development server with hot reloading. Trunk abstracts complexities like wasm-bindgen, asset hashing, and tree-shaking, enabling developers to focus on code.
Key features include single-command builds for production (trunk build), live-reloading dev server (trunk dev or trunk serve), and support for Tailwind CSS, image optimization, and more via plugins. Install via cargo install trunk. Ideal for SPAs, static sites, or PWAs in Rust. Outputs a dist/ directory ready for hosting on CDNs or servers.
CAVEATS
Requires Rust toolchain and wasm32-unknown-unknown target (rustup target add wasm32-unknown-unknown). Not for non-web Rust projects. Large initial builds possible.
MAIN SUBCOMMANDS
build: Produce production bundle.
dev or serve: Start dev server with HMR.
clean: Remove dist/.
EXAMPLE USAGE
trunk dev # Dev server on localhost:8080
trunk build --release # Production build
HISTORY
Developed by Brocode starting in 2020 as an open-source project on GitHub (trunk-rs/trunk). Gained popularity for simplifying Rust+WASM web dev, with regular releases adding plugin support, Tailwind integration, and performance improvements. Now at v1.x with 10k+ stars.
SEE ALSO
cargo(1), wasm-pack(1), tailwindcss(1)


