Fixed sass tool

This commit is contained in:
YuKun Liu committed 2022-05-10 13:46:53 +08:00
1 parent d10f9cc1e3
commit 8b06fe6059
2 files changed
+10 -10

No files matched your search

+2 -2
View File
@@ -47,10 +47,10 @@ binaryen = { wasm_opt = true }
# use sass auto will auto check sass file and build it.
[application.tools.sass]
# if auto = true, we will check style array, and translate all sass file to css.
# auto will check the assets dirs, and auto to transform all scss file to css file.
auto = true
# or you can specify some sass file -> css file
# you can specify some scss file -> css file
files = [
# some sass file path
# this file will translate to `/css/test.css`
+8 -8
View File
@@ -30,7 +30,6 @@ pub fn build(config: &CrateConfig) -> Result<()> {
..
} = config;
// start to build the assets
build_assets(config)?;
@@ -359,20 +358,21 @@ fn build_assets(config: &CrateConfig) -> Result<()> {
// if the sass open auto, we need auto-check the assets dir.
let asset_dir = config.asset_dir.clone();
if asset_dir.is_dir() {
for entry in walkdir::WalkDir::new(asset_dir)
for entry in walkdir::WalkDir::new(&asset_dir)
.into_iter()
.filter_map(|e| e.ok())
{
let temp = entry.path();
if temp.is_file() {
let suffix = temp.file_name().unwrap().to_str().unwrap();
let suffix = suffix.split('.').collect::<Vec<&str>>();
let suffix: &str = suffix.last().unwrap();
let suffix = temp.extension().unwrap().to_str().unwrap();
if suffix == "scss" {
// if file suffix is `scss` we need transform it.
let temp_stem = temp.file_stem().unwrap().to_str().unwrap();
let target_path =
temp.parent().unwrap().join(format!("{}.css", temp_stem));
let out_file =
format!("{}.css", temp.file_stem().unwrap().to_str().unwrap());
let target_path = config
.out_dir
.join(temp.strip_prefix(&asset_dir).unwrap().parent().unwrap())
.join(out_file);
sass.call(
"sass",
vec![temp.to_str().unwrap(), target_path.to_str().unwrap()],