「🌐 Language」简体中文
rsw = rs(rust) → w(wasm)
- A command-line tool for automatically rebuilding local changes, based on the wasm-pack
implementation.
rsw-rs
Feature
- rsw init
- rsw watch
- rsw build
- rsw new
wasm-pack
rsw
user
- debug info
TODO
- local sub-dependency file changes trigger hot updates
- integrate front-end scaffolding, such as
vite
,webpack
, etc.
Pre-installed
Usage
# Rust
# Or Node.js
# help
# rsw.toml - initial configuration
# generate a wasm project
# dev mode
# release mode
Logger
# @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
# 2. all: info, trace, debug, error, warn
RUST_LOG=rsw
rsw.toml
configuration file
Options
Create rsw.toml
in the project root path, configure the rust crate
parameter, and run the rsw watch
or rsw build
command.
name
- Profile name (optional)version
- Profile version (optional)interval
- Development modersw watch
, time interval for file changes to triggerwasm-pack build
, default50
milliseconds[new]
- Quickly generate a crate withwasm-pack new
, or set a custom template inrsw.toml -> [new] -> using
using
-wasm-pack
|rsw
|user
, default iswasm-pack
wasm-pack
-rsw new <name> --template <template> --mode <normal|noinstall|force>
wasm-pack new docrsw
-rsw new <name>
, built-in templatesuser
-rsw new <name>
, ifdir
is not configured, usewasm-pack new <name>
to initialize the project.
dir
- Copy all files in this directory. This field needs to be configured whenusing = "user"
.using = "wasm-pack"
orusing = "rsw"
, this field will be ignored
[[crates]]
- Is an array that supports multiplerust crate
configurationsname
- npm package name, supporting organization, e.g.@rsw/foo
root
- Relative to the project root path, default is.
target
-bundler
|nodejs
|web
|no-modules
, default isweb
out-dir
- npm package output path, defaultpkg
[crates.watch]
- Development moderun
- Whether thiscrate
needs to be watching, default istrue
profile
-dev
|profiling
, default isdev
[crates.build]
- Production moderun
- Whether thiscrate
needs to be build, default istrue
profile
-release
|profiling
, default isrelease
Note: name
in [[crates]]
is required, other fields are optional.
rsw.log
watch info
[RSW::ERROR]
[RSW::ARGS]
[RSW::BUILD]
[RSW::WATCH]
[RSW::FILE]
Example
# rsw.toml
= "rsw"
= "0.1.0"
#! default is `50` ms
= 50
#! ---------------------------
#! rsw new <name>
[]
#! @see https://rustwasm.github.io/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
= "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
= "my-template"
#! ################# NPM Package #################
#! When there is only `name`, other fields will use the default configuration
#! -------- package: rsw-hello --------
[[]]
= "rsw-hello"
#! =======================================================
#! -------- package: @rsw/hello --------
# [[crates]]
# #! npm package name
# name = "@rsw/hello"
# #! default is `.`
# root = "."
# #! default is `pkg`
# out-dir = "pkg"
# #! target: bundler | nodejs | web | no-modules, default is `web`
# target = "web"
# #! rsw watch
# [crates.watch]
# #! default is `true`
# run = false
# #! profile: `dev` | `profiling`, default is `dev`
# profile = "dev"
# #! rsw build
# [crates.build]
# run = false
# #! profile: `release` | `profiling`, default is `release`
# profile = "release"
License
MIT License © 2022 lencx