Skip to content
Tauri 中文网

主干

Trunk 是一个用于 Rust 的 WASM 网络应用打包工具。更多关于 Trunk 的信息,请访问 https://trunk-rs.github.io/trunk/。本指南适用于 Trunk 0.17.5 版本。

🌐 Trunk is a WASM web application bundler for Rust. Learn more about Trunk at https://trunk-rs.github.io/trunk/. This guide is accurate as of Trunk 0.17.5.

🌐 Checklist

  • 使用 SSG,Tauri 不正式支持基于服务器的解决方案。
  • 使用 serve.ws_protocol = "ws",以便热重载 WebSocket 能够正确连接,用于移动开发。
  • 启用 withGlobalTauri 以确保 Tauri API 可在 window.__TAURI__ 变量中使用,并且可以使用 wasm-bindgen 导入。

🌐 Example Configuration

  1. tauri.conf.json
    {
    "build": {
    "beforeDevCommand": "trunk serve",
    "beforeBuildCommand": "trunk build",
    "devUrl": "http://localhost:8080",
    "frontendDist": "../dist"
    },
    "app": {
    "withGlobalTauri": true
    }
    }
  2. Trunk.toml
    [watch]
    ignore = ["./src-tauri"]
    [serve]
    ws_protocol = "ws"

Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站