Skip to content

Commit a9f69e8

Browse files
authored
Merge pull request #1235 from epage/minify
chore: Upgrade html_minifier
2 parents dc8fbd5 + 81ad44c commit a9f69e8

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

Cargo.lock

+5-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ notify = { version = "8", optional = true, default-features = false, features =
175175

176176
sass-rs = { version = "0.2", optional = true }
177177

178-
html-minifier = {version="3.0", optional = true }
178+
html-minifier = {version="5.0", optional = true }
179179
anyhow = "1.0.97"
180180
anstream = "0.6.18"
181181
chrono = "0.4.40"

src/cobalt_model/assets.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ fn copy_and_minify_css(src_file: &path::Path, dest_file: &path::Path, minify: bo
8282
dest_file.display()
8383
);
8484
let content = std::fs::read_to_string(src_file)?;
85-
let minified = minify(&content).map_err(|e| {
86-
anyhow::format_err!(
87-
"Could not minify css file {} error {}",
88-
src_file.to_string_lossy(),
89-
e
90-
)
91-
})?;
85+
let minified = minify(&content)
86+
.map_err(|e| {
87+
anyhow::format_err!(
88+
"Could not minify css file {} error {}",
89+
src_file.to_string_lossy(),
90+
e
91+
)
92+
})?
93+
.to_string();
9294
std::fs::write(dest_file, minified)?;
9395
} else {
9496
files::copy_file(src_file, dest_file)?;
@@ -112,7 +114,8 @@ fn copy_and_minify_js(src_file: &path::Path, dest_file: &path::Path, minify: boo
112114
dest_file.display()
113115
);
114116
let content = std::fs::read_to_string(src_file)?;
115-
std::fs::write(dest_file, minify(&content))?;
117+
let minified = minify(&content).to_string();
118+
std::fs::write(dest_file, minified)?;
116119
} else {
117120
files::copy_file(src_file, dest_file)?;
118121
}

src/cobalt_model/sass.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ impl SassCompiler {
8282
#[cfg(feature = "html-minifier")]
8383
let content = if minify.css {
8484
use html_minifier::css::minify;
85-
minify(&content).map_err(|e| {
86-
anyhow::format_err!(
87-
"Could not minify saas file {} error {}",
88-
source.to_string_lossy(),
89-
e
90-
)
91-
})?
85+
minify(&content)
86+
.map_err(|e| {
87+
anyhow::format_err!(
88+
"Could not minify saas file {} error {}",
89+
source.to_string_lossy(),
90+
e
91+
)
92+
})?
93+
.to_string()
9294
} else {
9395
content
9496
};

0 commit comments

Comments
 (0)