21 个版本 (8 个重大更新)
| 0.8.0 | 2022 年 11 月 16 日 |
|---|---|
| 0.7.11 | 2022 年 9 月 11 日 |
| 0.7.10 | 2022 年 5 月 24 日 |
| 0.7.3 | 2022 年 3 月 5 日 |
在 WebAssembly 中排名第 340
每月下载量 342 次
59KB
1.5K SLoC
rsw-rs
rsw = rs(rust) → w(wasm) - 基于wasm-pack实现自动重建本地更改的命令行工具。
英文 | 简体中文
已预装
使用方法
# Rust - install globally
cargo install rsw
# help
rsw -h
# rsw.toml - initial configuration
rsw init
# generate a wasm project
rsw new <name>
# dev mode
rsw watch
# release mode
rsw build
# clean - link & build
rsw clean
出色的 rsw
- [rsw 示例] learn-wasm - 🎲 学习 WebAssembly
- vite-plugin-rsw - 🦀 wasm-pack 插件 for Vite
- create-mpl - ⚡️ 几秒钟内创建项目!
- Oh My Box - 🔮 开发工具箱,更多...
日志记录器
# @see: https://github.com/env-logger-rs/env_logger
# RUST_LOG=rsw=<info|trace|debug|error|warn> rsw <watch|build|new>
# 1. info
RUST_LOG=rsw=info rsw <SUBCOMMAND>
# 2. all: info, trace, debug, error, warn
RUST_LOG=rsw rsw <SUBCOMMAND>
.watchignore
定义要忽略的文件/路径。类似于 .gitignore。
示例
# .watchignore
*.js
a/b/**/*.txt
!a/b/**/main.txt
rsw.toml
配置文件
选项
在项目根目录下创建 rsw.toml,配置 rust crate 参数,并运行 rsw watch 或 rsw build 命令。
name- 配置文件名称(可选)version- 配置文件版本(可选)interval- 开发模式rsw watch,触发wasm-pack build的文件更改时间间隔,默认50毫秒cli-npm|yarn|pnpm,默认是npm。使用指定的cli执行link,例如npm link[new]- 使用wasm-pack-pack new快速生成一个 crate,或者在rsw.toml -> [new] -> usingusing-wasm-pack|rsw|user,默认是wasm-packwasm-pack-rsw new <name> --template <template> --mode <normal|noinstall|force>wasm-pack new docrsw-rsw new <name>,内置模板user-rsw new <name>,如果未配置dir,则使用wasm-pack new <name>来初始化项目。
dir- 复制此目录下所有文件。当using = "user"时需要配置此字段。对于using = "wasm-pack"或using = "rsw",此字段将被忽略
[[crates]]- 是一个支持多个rust crate配置的数组name- npm 包名,支持组织,例如@rsw/fooroot- 相对于项目根路径,默认是.link-true|false,默认是false,在构建此rust crate之后是否执行link命令target-bundler|nodejs|web|no-modules,默认是webscope- npm 组织out-dir- npm 包输出路径,默认pkg[crates.watch]- 开发模式run- 是否需要监控此crate,默认是trueprofile-dev|profiling,默认为dev
[crates.build]- 生产模式run- 是否需要构建此crate,默认为trueprofile-release|profiling,默认为release
注意:在 [[crates]] 中 name 是必需的,其他字段是可选的。
.rsw
rsw watch- 临时目录
- rsw.info - 关于
watch模式的信息[RSW::OK][RSW::ERR][RSW::NAME][RSW::PATH][RSW::BUILD]
- rsw.err -
wasm-pack build错误 - rsw.crates
示例
# rsw.toml
name = "rsw"
version = "0.1.0"
#! time interval for file changes to trigger wasm-pack build, default `50` milliseconds
interval = 50
#! link
#! npm link @see https://docs.npmjs.net.cn/cli/v8/commands/npm-link
#! yarn link @see https://yarn-classic.npmjs.net.cn/en/docs/cli/link
#! pnpm link @see https://pnpm.npmjs.net.cn/cli/link
#! The link command will only be executed if `[[crates]] link = true`
#! cli: `npm` | `yarn` | `pnpm`, default is `npm`
cli = "npm"
#! ---------------------------
#! rsw new <name>
[new]
#! @see https://wasm.rust-lang.net.cn/docs/wasm-pack/commands/new.html
#! using: `wasm-pack` | `rsw` | `user`, default is `wasm-pack`
#! 1. wasm-pack: `rsw new <name> --template <template> --mode <normal|noinstall|force>`
#! 2. rsw: `rsw new <name>`, built-in templates
#! 3. user: `rsw new <name>`, if `dir` is not configured, use `wasm-pack new <name>` to initialize the project
using = "wasm-pack"
#! this field needs to be configured when `using = "user"`
#! `using = "wasm-pack"` or `using = "rsw"`, this field will be ignored
#! copy all files in this directory
dir = "my-template"
#! ################# NPM Package #################
#! When there is only `name`, other fields will use the default configuration
#! 📦 -------- package: rsw-hello --------
[[crates]]
#! npm package name (path: $ROOT/rsw-hello)
name = "rsw-hello"
#! run `npm link`: `true` | `false`, default is `false`
link = false
#! 📦 -------- package: @rsw/utils --------
[[crates]]
#! npm package name (path: $ROOT/utils)
name = "utils"
# #! scope: npm org
scope = "rsw"
#! run `npm link`: `true` | `false`, default is `false`
link = false
#! 📦 -------- package: @rsw/hello --------
[[crates]]
#! npm package name (path: $ROOT/@rsw/hello)
name = "@rsw/hello"
#! default is `.`
root = "."
#! default is `pkg`
out-dir = "pkg"
#! target: bundler | nodejs | web | no-modules, default is `web`
target = "web"
#! run `npm link`: `true` | `false`, default is `false`
link = false
#! rsw watch
[crates.watch]
#! default is `true`
run = true
#! profile: `dev` | `profiling`, default is `dev`
profile = "dev"
#! rsw build
[crates.build]
#! default is `true`
run = true
#! profile: `release` | `profiling`, default is `release`
profile = "release"
许可证
MIT 许可证 © 2022 lencx
依赖
~11–23MB
~324K SLoC