1 个不稳定版本
0.1.0 | 2019年10月4日 |
---|
#408 in Cargo 插件
55KB
1.5K SLoC
cargo-node
一个 cargo 子命令,用于构建、运行和部署作为浏览器、electron 或 cordova 应用程序的 rust wasm 应用。
功能
目前你可以使用以下命令
- 构建你的项目
cargo node build
- 运行你的项目
cargo node run
- 部署你的项目
cargo node deploy
你可以在命令行上使用额外的标志
- 定义目标平台(electron | browser | android),默认为 electron
cargo node run --target browser
- 切换到发布构建
cargo node deploy --release
- 构建、运行或部署示例
cargo node run --example my_example
安装
cargo install cargo node
在你能使用 cargo node 之前,你必须安装 npm
版本 6.9.0。它包含在 Node.js
版本 10.16.3 中。你可以从 https://node.org.cn/dist/v10.16.3/ 下载。
假设你已经安装了 Rust 的 cargo
。cargo node 的所有其他依赖都将自动安装。
Node.toml
cargo node
提供了一个可选的配置文件,你可以将其放在 cargo
的 Cargo.toml
旁边。
示例
[[apps]]
# Name of the executable
name = "my app"
# Defines the window width of the electron window
width = 300
# Defines the height of the electron window
height = 100
# Path of the assets folder with images, fonts, ...
assets = "assets/"
# Add custom fonts to your project
[[apps.fonts]]
font_family = "My Font"
src = "fonts/MyFont.ttf"
底层的工具
- cargo-web (Apache-2.0): https://github.com/koute/cargo-web 用于将你的 rust 应用程序构建为客户端 Web 应用程序
- npm (The Artistic License 2.0): https://github.com/npm/cli 用于安装和处理 electron、electron-packer 和 cordova
- electron (MIT): https://github.com/electron/electron 用于构建、运行 Linux、macOS 和 Windows 的桌面应用程序
- electron-packager (BSD-2-Clause): https://github.com/electron/electron-packager 用于部署 Linux、macOS 和 Windows 的桌面应用程序
- cordova (Apache-2.0): https://github.com/apache/cordova-cli 用于构建、运行 Android 移动应用程序
- wasm2js (Apache-2.0): https://github.com/WebAssembly/binaryen 用于将 wasm 文件转换为javascript,作为在 Android 上加载 wasm 的解决方案
许可证
根据 MIT 许可证授权(LICENSE)。
依赖项
~4.5–6.5MB
~121K SLoC