Add files list option

This commit is contained in:
YuKun Liu committed 2022-05-10 19:22:19 +08:00
1 parent 8b06fe6059
commit b5ecd09185
2 files changed
+23 -1

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ binaryen = { wasm_opt = true }
# auto will check the assets dirs, and auto to transform all scss file to css file.
auto = true
# you can specify some scss file -> css file
# or you can specify some scss file -> css file
files = [
# some sass file path
# this file will translate to `/css/test.css`
+22
View File
@@ -381,6 +381,28 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
}
}
}
} else if tab.contains_key("files") && tab.get("files").unwrap().is_array() {
// check files list.
let list = tab.get("files").unwrap().as_array().unwrap();
for i in list {
if i.is_str() {
let path = i.as_str().unwrap();
let path = PathBuf::from(path);
let path = config.asset_dir.join(path);
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(),
],
)?;
}
}
}
}
}
}