-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add minification process #50632
Add minification process #50632
Conversation
For the record, here's the error:
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Is there a reason you are tying to build it as a dylib? https://github.com/GuillaumeGomez/minifier-rs/blob/81851f08301dd149c2de25889ade81291ca6de74/Cargo.toml#L23 |
Old (and bad apparently) habit. Good catch, thanks a lot! |
9864b36
to
649ab69
Compare
Fixed the initial issue, now just need to make the minification process work as expected. :) |
d0011a1
to
3a51b0a
Compare
src/librustdoc/html/render.rs
Outdated
include_bytes!("static/main.js"), | ||
enable_minification)?; | ||
write_minify(cx.dst.join(&format!("settings{}.js", cx.shared.resource_suffix)), | ||
include_bytes!("static/settings.js"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we minimize these two *.js
files at build.rs
of rustdoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather prefer that we don't. We could but then disabling minification would be a bit more complicated and I'm not sure it's worth it.
src/librustdoc/html/render.rs
Outdated
@@ -1020,6 +1028,18 @@ fn write(dst: PathBuf, contents: &[u8]) -> Result<(), Error> { | |||
Ok(try_err!(fs::write(&dst, contents), &dst)) | |||
} | |||
|
|||
fn write_minify(dst: PathBuf, contents: &[u8], enable_minification: bool) -> Result<(), Error> { | |||
if enable_minification { | |||
if let Ok(s) = String::from_utf8(contents.to_vec()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use include_str!
instead of include_bytes!
for the static files to avoid this UTF-8 check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
3a51b0a
to
e2db0a5
Compare
Updated following @ollie27's comment. |
Seems good to me. What do you think, @ollie27? |
Yeah this looks good. For the |
For now it's experimental. If we have no issue for a given time, we might want to expand this to other tools as well. Thanks for your review! @bors: r=ollie27 |
📌 Commit e2db0a5 has been approved by |
Add minification process r? @QuietMisdreavus
Rollup of 11 pull requests Successful merges: - #49767 (Rewrite docs for `std::ptr`) - #50399 (save-analysis: handle aliasing imports a bit more nicely) - #50594 (Update the man page with additional --print options) - #50613 (Migrate the toolstate update bot to rust-highfive) - #50632 (Add minification process) - #50685 (ci: Add Dockerfile for dist-sparc64-linux) - #50691 (rustdoc: Add support for pub(restricted)) - #50712 (Improve eager type resolution error message) - #50720 (Add “Examples” section header in f32/f64 doc comments.) - #50733 (Hyperlink DOI against preferred resolver) - #50745 (Uncapitalize "You") Failed merges:
r? @QuietMisdreavus