mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
Minify output (closes #1)
This commit is contained in:
parent
f10bb9f068
commit
2660ede3dc
3 changed files with 47 additions and 2 deletions
|
@ -174,7 +174,10 @@ impl<'a> SiteBuilder<'a> {
|
|||
rewriter.write(out.as_bytes())?;
|
||||
rewriter.end()?;
|
||||
|
||||
let out = String::from_utf8(output)?;
|
||||
let mut out = String::from_utf8(output)?;
|
||||
if !self.serving {
|
||||
out = minifier::html::minify(&out);
|
||||
}
|
||||
|
||||
let out_path = self.build_path.join(page_name).with_extension("html");
|
||||
std::fs::create_dir_all(out_path.parent().unwrap())
|
||||
|
@ -205,7 +208,12 @@ impl<'a> SiteBuilder<'a> {
|
|||
let sheet_path = sass_path.join(sheet);
|
||||
if let Some(sheet_path) = sheet_path.to_str() {
|
||||
match grass::from_path(sheet_path, &grass::Options::default()) {
|
||||
Ok(css) => {
|
||||
Ok(mut css) => {
|
||||
if !self.serving {
|
||||
css = minifier::css::minify(&css)
|
||||
.map_err(|err| anyhow::anyhow!(err))?
|
||||
.to_string();
|
||||
}
|
||||
std::fs::write(styles_path.join(sheet).with_extension("css"), css)
|
||||
.with_context(|| {
|
||||
format!("Failed to write new CSS file for Sass: {:?}", sheet)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue