Skip to content

Commit

Permalink
feat: added greater control over minification
Browse files Browse the repository at this point in the history
This adds feature-level control over JS and CSS minification (both on by
default). If one isn't working, it can be disabled without affecting the
others. Also updated `minify-html` to v0.10.1, which makes it work!
  • Loading branch information
arctic-hen7 committed Sep 29, 2022
1 parent 9e7363f commit 5385f12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/perseus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fs_extra = "1"
http = "0.2"
urlencoding = "2.1"
chrono = "0.4"
minify-html-onepass = "0.10"
minify-html-onepass = "0.10.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
rexie = { version = "0.2", optional = true }
Expand All @@ -49,7 +49,7 @@ wasm-bindgen-futures = "0.4"
[features]
# Live reloading will only take effect in development, and won't impact production
# BUG This adds 1.9kB to the production bundle (that's without size optimizations though)
default = [ "live-reload", "hsr", "client-helpers", "macros", "dflt-engine", "minify" ]
default = [ "live-reload", "hsr", "client-helpers", "macros", "dflt-engine", "minify", "minify-js", "minify-css" ]
translator-fluent = ["fluent-bundle", "unic-langid", "intl-memoizer"]
translator-lightweight = []
# This feature adds support for a number of macros that will make your life MUCH easier (read: use this unless you have very specific needs or are completely insane)
Expand All @@ -61,6 +61,8 @@ client-helpers = [ "console_error_panic_hook" ]
# This feature enables the minification of HTML, CSS, and JS assets, improving your page load speeds. You should only disable this if you're having issues with invalid
# HTML.
minify = []
minify-js = [ "minify" ]
minify-css = [ "minify" ]
# This feature enables Sycamore hydration by default (Sycamore hydration feature is always activated though)
# This is not enabled by default due to some remaining bugs (also, default features in Perseus can't be disabled without altering `.perseus/`)
hydrate = []
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/utils/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub(crate) fn minify(code: &str, minify_extras: bool) -> Result<String, ServerEr
// let them disable this feature
if cfg!(feature = "minify") {
let cfg = Cfg {
minify_js: false, // Pending wilsonzlin/minify-js#1
minify_css: minify_extras,
minify_js: minify_extras && cfg!(feature = "minify-js"),
minify_css: minify_extras && cfg!(feature = "minify-css"),
};
let mut bytes = code.as_bytes().to_vec();

Expand Down

0 comments on commit 5385f12

Please sign in to comment.