From 7ace63a6c54270948c1b347c9ac17d64c2dbd20b Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sun, 9 Jul 2017 11:37:05 +0900 Subject: [PATCH] Use compile_file for sass --- components/site/src/lib.rs | 7 +++---- components/site/test_site/sass/_included.scss | 3 +++ components/site/test_site/sass/blog.scss | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 components/site/test_site/sass/_included.scss diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 13a0f2b9..ffea52ba 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -32,11 +32,11 @@ use tera::{Tera, Context}; use walkdir::WalkDir; #[cfg(not(target_os = "windows"))] -use sass_rs::{Options, compile_string}; +use sass_rs::{Options, compile_file}; use errors::{Result, ResultExt}; use config::{Config, get_config}; -use utils::fs::{create_file, read_file, create_directory, ensure_directory_exists}; +use utils::fs::{create_file, create_directory, ensure_directory_exists}; use content::{Page, Section, populate_previous_and_next_pages, sort_pages}; use templates::{GUTENBERG_TERA, global_fns, render_redirect_template}; use front_matter::{SortBy, InsertAnchor}; @@ -462,8 +462,7 @@ impl Site { for file in files { let name = file.as_path().file_stem().unwrap().to_string_lossy(); - let content = read_file(&file)?; - let css = match compile_string(&content, Options::default()) { + let css = match compile_file(file.as_path().to_str().unwrap(), Options::default()) { Ok(c) => c, Err(e) => bail!(e) }; diff --git a/components/site/test_site/sass/_included.scss b/components/site/test_site/sass/_included.scss new file mode 100644 index 00000000..38fb2b9c --- /dev/null +++ b/components/site/test_site/sass/_included.scss @@ -0,0 +1,3 @@ +.container { + font-size: 2rem; +} diff --git a/components/site/test_site/sass/blog.scss b/components/site/test_site/sass/blog.scss index ec8af3eb..5a003615 100644 --- a/components/site/test_site/sass/blog.scss +++ b/components/site/test_site/sass/blog.scss @@ -5,3 +5,5 @@ body { background: blue; } } + +@import "included";