diff --git a/components/site/src/minify.rs b/components/site/src/minify.rs index 46a48f4808..ceed8ff483 100644 --- a/components/site/src/minify.rs +++ b/components/site/src/minify.rs @@ -6,6 +6,8 @@ use libs::minify_html::{minify, Cfg}; pub fn html(html: String) -> Result { let mut cfg = Cfg::spec_compliant(); cfg.keep_html_and_head_opening_tags = true; + cfg.minify_css = true; + cfg.minify_js = true; let minified = minify(html.as_bytes(), &cfg); match std::str::from_utf8(&minified) { @@ -83,4 +85,61 @@ mod tests { let res = html(input.to_owned()).unwrap(); assert_eq!(res, expected); } + + // https://github.com/getzola/zola/issues/1765 + #[test] + fn can_minify_css() { + let input = r#" + + + + + + + + + +

Example blog post

+ + FOO BAR + + +"#; + let expected = r#"

Example blog post

FOO BAR"#; + let res = html(input.to_owned()).unwrap(); + assert_eq!(res, expected); + } + + // https://github.com/getzola/zola/issues/1765 + #[test] + fn can_minify_js() { + let input = r#" + + + + + + + + + +

Example blog post

+ + FOO BAR + + +"#; + let expected = r#"

Example blog post

FOO BAR"#; + let res = html(input.to_owned()).unwrap(); + assert_eq!(res, expected); + } } +