Loading...
Loading...
Guides users through Tauri binary size optimization techniques to produce small, efficient desktop application bundles using Cargo profile settings and build configurations.
npx skill4agent add dchuk/claude-code-tauri-skills optimizing-tauri-binary-size| Framework | Minimum Binary Size |
|---|---|
| Tauri | ~3-6 MB |
| Electron | ~120-180 MB |
| NW.js | ~80-100 MB |
src-tauri/Cargo.toml[profile.release]
codegen-units = 1 # Compile crates one at a time for better LLVM optimization
lto = true # Enable link-time optimization across all crates
opt-level = "s" # Optimize for binary size (alternative: "z" for even smaller)
panic = "abort" # Remove panic unwinding code
strip = true # Strip debug symbols from final binary| Option | Values | Description |
|---|---|---|
| | Reduces parallelism but allows LLVM to perform better whole-program optimization |
| | Link-time optimization; |
| | |
| | Removes panic handler code, reducing binary size |
| | Removes symbols and debug information from binary |
[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
panic = "abort"
strip = true
trim-paths = "all" # Remove file path information from binary
[profile.release.build-override]
opt-level = "s" # Also optimize build scripts[profile.release]
rustflags = ["-Cdebuginfo=0", "-Zthreads=8"]tauri.conf.json{
"build": {
"removeUnusedCommands": true
}
}src-tauri/Cargo.toml[dependencies]
tauri = { version = "2", features = ["macos-private-api"] }
# Avoid enabling unnecessary features like:
# - "devtools" in production
# - "protocol-asset" if not serving local assets
# - "tray-icon" if not using system traycd src-tauri
cargo tauri build --releasecd src-tauri
cargo +nightly tauri build --release# macOS
ls -lh src-tauri/target/release/bundle/macos/*.app/Contents/MacOS/*
# Linux
ls -lh src-tauri/target/release/bundle/appimage/*.AppImage
# Windows
dir src-tauri\target\release\bundle\msi\*.msisrc-tauri/Cargo.toml[package]
name = "my-tauri-app"
version = "0.1.0"
edition = "2021"
[dependencies]
tauri = { version = "2", features = [] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
panic = "abort"
strip = true
[profile.release.package."*"]
opt-level = "s"tauri.conf.json{
"productName": "my-tauri-app",
"version": "0.1.0",
"identifier": "com.example.my-tauri-app",
"build": {
"removeUnusedCommands": true,
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"bundle": {
"active": true,
"targets": "all",
"icon": ["icons/icon.png"]
}
}| Setting | Size Impact | Build Time | Runtime Performance |
|---|---|---|---|
| Smaller | Slower | Better |
| Smaller | Much slower | Better |
| Smaller | Similar | Slightly slower |
| Smallest | Similar | Slower |
| Smaller | Faster | No unwinding |
| Smaller | Similar | No impact |
--releasecargo treefilelto = truelto = "thin"rustup install nightly
rustup default nightly
# Or use +nightly flag with cargo commands