From b5ecd09185062724415e9bf7b6b10d7e2c6860e8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 19:22:19 +0800 Subject: [PATCH] Add `files` list option --- src/assets/dioxus.toml | 2 +- src/builder.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 105251aa1..5f5032e2a 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -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` diff --git a/src/builder.rs b/src/builder.rs index 0e0cf7e9a..fb0c8088d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -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(), + ], + )?; + } + } + } } } }