Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsw"
version = "0.8.0"
version = "0.9.0"
description = "wasm-pack based build tool"
edition = "2021"
authors = ["lencx <cxin1314@gmail.com>"]
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ pub struct WatchOptions {
/// which helps when investigating performance issues in a profiler.
#[serde(default = "default_dev")]
pub profile: Option<String>,
/// Cargo features to activate for this crate in "watch" mode.
#[serde(default)]
pub features: Option<Vec<String>>,
}

/// `rsw build` - build config
Expand All @@ -89,6 +92,9 @@ pub struct BuildOptions {
/// which helps when investigating performance issues in a profiler.
#[serde(default = "default_release")]
pub profile: Option<String>,
/// Cargo features to activate for this crate in "build" mode.
#[serde(default)]
pub features: Option<Vec<String>>,
}

/// `rsw new` - new config
Expand Down Expand Up @@ -203,12 +209,14 @@ fn default_watch() -> Option<WatchOptions> {
Some(WatchOptions {
run: default_true(),
profile: default_dev(),
features: Some(vec![]),
})
}

fn default_build() -> Option<BuildOptions> {
Some(BuildOptions {
run: default_true(),
profile: default_release(),
features: Some(vec![]),
})
}
6 changes: 6 additions & 0 deletions src/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ impl Build {

// profile
let mut profile = config.build.as_ref().unwrap().profile.as_ref().unwrap();
let mut features = config.build.as_ref().unwrap().features.as_ref().unwrap();
if rsw_type == "watch" {
profile = config.watch.as_ref().unwrap().profile.as_ref().unwrap();
features = config.watch.as_ref().unwrap().features.as_ref().unwrap();
}
let arg_profile = format!("--{}", profile);
let arg_features = format!("--features={}", features.join(","));
args.push(&arg_profile);
if !features.is_empty() {
args.push(&arg_features);
}

// scope
let (_, scope2) = get_pkg(&self.config.name);
Expand Down