Remove auto option

This commit is contained in:
YuKun Liu committed 2022-05-10 22:58:48 +08:00
1 parent 551d2477ff
commit 9ddaa773d9
1 file changed
+41 -6
+41 -6
View File
@@ -362,10 +362,14 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
"--no-source-map" "--no-source-map"
} }
} else { } else {
"--no-source-map" "--source-map"
}; };
if tab.contains_key("auto") && tab.get("auto").unwrap().as_bool().unwrap_or(false) { if tab.contains_key("files") {
if tab.get("files").unwrap().is_str() {
let file = tab.get("files").unwrap().as_str().unwrap().trim();
if file == "*" {
// if the sass open auto, we need auto-check the assets dir. // if the sass open auto, we need auto-check the assets dir.
let asset_dir = config.asset_dir.clone(); let asset_dir = config.asset_dir.clone();
if asset_dir.is_dir() { if asset_dir.is_dir() {
@@ -378,11 +382,18 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
let suffix = temp.extension().unwrap().to_str().unwrap(); let suffix = temp.extension().unwrap().to_str().unwrap();
if suffix == "scss" { if suffix == "scss" {
// if file suffix is `scss` we need transform it. // if file suffix is `scss` we need transform it.
let out_file = let out_file = format!(
format!("{}.css", temp.file_stem().unwrap().to_str().unwrap()); "{}.css",
temp.file_stem().unwrap().to_str().unwrap()
);
let target_path = config let target_path = config
.out_dir .out_dir
.join(temp.strip_prefix(&asset_dir).unwrap().parent().unwrap()) .join(
temp.strip_prefix(&asset_dir)
.unwrap()
.parent()
.unwrap(),
)
.join(out_file); .join(out_file);
sass.call( sass.call(
"sass", "sass",
@@ -396,7 +407,28 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
} }
} }
} }
} else if tab.contains_key("files") && tab.get("files").unwrap().is_array() { } else {
// just transform one file.
let path = config.asset_dir.join(file);
if path.is_file() {
sass.call(
"sass",
vec![
path.to_str().unwrap(),
path.parent()
.unwrap()
.join(format!(
"{}.css",
path.file_stem().unwrap().to_str().unwrap()
))
.to_str()
.unwrap(),
source_map,
],
)?;
}
}
} else if tab.get("files").unwrap().is_array() {
// check files list. // check files list.
let list = tab.get("files").unwrap().as_array().unwrap(); let list = tab.get("files").unwrap().as_array().unwrap();
for i in list { for i in list {
@@ -426,6 +458,9 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
} }
} }
} }
}
// SASS END
Ok(()) Ok(())
} }