LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

trunk

Rust WebAssembly application bundler

TLDR

Build the project
$ trunk build
copy
Build for release with optimizations
$ trunk build --release
copy
Serve with hot reload
$ trunk serve
copy
Serve on a specific port and address
$ trunk serve --port [3000] --address [0.0.0.0]
copy
Serve with a backend proxy
$ trunk serve --proxy-backend=http://localhost:[9000]/api/
copy
Watch for changes and rebuild
$ trunk watch
copy
Clean build artifacts
$ trunk clean
copy

SYNOPSIS

trunk command [--release] [options]

DESCRIPTION

Trunk is a build tool for Rust WebAssembly applications that handles compilation, bundling, and serving. It compiles Rust code to WebAssembly, processes assets like CSS and JavaScript, and generates the HTML and JavaScript glue code needed to run WASM modules in the browser.
The development server provides hot reloading, automatically rebuilding and refreshing the browser when source files change. Release builds apply optimizations including WASM size reduction for production deployment.
Trunk integrates with wasm-bindgen for JavaScript interop and works with frameworks like Yew, Leptos, and Seed. Configuration is managed through a Trunk.toml file in the project root.

PARAMETERS

build

Build the project, compiling Rust to WASM and bundling assets.
serve
Start development server with hot reloading.
watch
Watch for file changes and rebuild automatically.
clean
Remove build artifacts (dist directory).
--release
Enable release optimizations including WASM size reduction.
--public-url URL
Public URL prefix for asset paths.
--port PORT
Port for the dev server (default: 8080).
--address ADDR
Address to bind the dev server to.
--proxy-backend URL
Proxy requests to a backend server. The URI path of the URL determines the proxy path.
--proxy-rewrite URI
Alternative URI on which to listen for proxy requests.

CONFIGURATION

Trunk.toml

Project configuration file specifying build options, proxy settings, and asset pipeline rules.

CAVEATS

Rust/WASM specific. wasm-bindgen based. Trunk.toml config.

HISTORY

Trunk was created for building and bundling Rust WebAssembly applications.

SEE ALSO

wasm-pack(1), cargo(1)

Copied to clipboard
Kai