Update minifier version to 0.2.1
This commit is contained in:
parent
fee3a459dd
commit
edd26add3b
5 changed files with 11 additions and 8 deletions
|
@ -2391,9 +2391,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minifier"
|
name = "minifier"
|
||||||
version = "0.1.0"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7071d17e2898e134cabf624f43cdefa0cedf57c739e964df3d0df9d028701a72"
|
checksum = "ac96d1e7a65f206443f95afff6de8f1690c77c97d6fc9c9bb2d2cd0662e9ff9f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimal-lexical"
|
name = "minimal-lexical"
|
||||||
|
|
|
@ -11,7 +11,7 @@ arrayvec = { version = "0.7", default-features = false }
|
||||||
askama = { version = "0.11", default-features = false, features = ["config"] }
|
askama = { version = "0.11", default-features = false, features = ["config"] }
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
pulldown-cmark = { version = "0.9", default-features = false }
|
pulldown-cmark = { version = "0.9", default-features = false }
|
||||||
minifier = "0.1.0"
|
minifier = "0.2.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
smallvec = "1.6.1"
|
smallvec = "1.6.1"
|
||||||
|
|
|
@ -122,11 +122,13 @@ impl Context<'_> {
|
||||||
if minify {
|
if minify {
|
||||||
let contents = contents.as_ref();
|
let contents = contents.as_ref();
|
||||||
let contents = if resource.extension() == Some(OsStr::new("css")) {
|
let contents = if resource.extension() == Some(OsStr::new("css")) {
|
||||||
minifier::css::minify(contents).map_err(|e| {
|
minifier::css::minify(contents)
|
||||||
|
.map_err(|e| {
|
||||||
Error::new(format!("failed to minify CSS file: {}", e), resource.path(self))
|
Error::new(format!("failed to minify CSS file: {}", e), resource.path(self))
|
||||||
})?
|
})?
|
||||||
|
.to_string()
|
||||||
} else {
|
} else {
|
||||||
minifier::js::minify(contents)
|
minifier::js::minify(contents).to_string()
|
||||||
};
|
};
|
||||||
self.write_shared(resource, contents, emit)
|
self.write_shared(resource, contents, emit)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -185,6 +185,7 @@ fn build_rule(v: &[u8], positions: &[usize]) -> String {
|
||||||
.intersperse(" ")
|
.intersperse(" ")
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
)
|
)
|
||||||
|
.map(|css| css.to_string())
|
||||||
.unwrap_or_else(|_| String::new())
|
.unwrap_or_else(|_| String::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ fn check_invalid_css() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_with_minification() {
|
fn test_with_minification() {
|
||||||
let text = include_str!("../html/static/css/themes/dark.css");
|
let text = include_str!("../html/static/css/themes/dark.css");
|
||||||
let minified = minifier::css::minify(&text).expect("CSS minification failed");
|
let minified = minifier::css::minify(&text).expect("CSS minification failed").to_string();
|
||||||
|
|
||||||
let against = load_css_paths(text.as_bytes());
|
let against = load_css_paths(text.as_bytes());
|
||||||
let other = load_css_paths(minified.as_bytes());
|
let other = load_css_paths(minified.as_bytes());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue