Trunk
Trunk 是一个用于 Rust 的 WASM 网络应用程序打包工具。要了解更多关于 Trunk 的信息,请访问 https://trunkrs.dev 。本指南适用于 Trunk 0.17.5 版本。
检查清单
- 使用 SSG。Tauri 不支持基于服务端的解决方案。
- 使用
ws_protocol = "ws"
以便进行移动开发时热重载 websocket 可以正常连接。 - 启用
withGlobalTauri
以确保 Tauri API 在使用window.__TAURI__
变量时可用,并且可以使用wasm-bindgen
导入。
示例配置
-
更新 Tauri 配置:
tauri.conf.json {"build": {"beforeDevCommand": "trunk serve","beforeBuildCommand": "trunk build","devUrl": "http://localhost:8080","frontendDist": "../dist"},"app": {"withGlobalTauri": true}} -
更新 Trunk 配置:
Trunk.toml [watch]ignore = ["./src-tauri"][serve]ws_protocol = "ws"
© 2025 Tauri Contributors. CC-BY / MIT