Skip to content

Commit

Permalink
feat(html/minifier): Support using custom css minifier (#9425)
Browse files Browse the repository at this point in the history
**Description:**

Support use a custom css minifier when minimizing html, add `feature =
"custom-css-minifier"` to enable this and remove the dependencies of
`swc_css_*`.
And `feature = "default-css-minifier"` keep the original behavior, using
`swc_css` when minimizing html, and this is the default feature.
(Rspack is now using LightningCSS to minimize CSS files, but the CSS
insides html is still using `swc_css` (which called by
`swc_html_minifier`) to do the minify, so we want to also use
LightningCSS to minify the CSS insides html to keep the consistent with
CSS files)
  • Loading branch information
ahabhgk authored Aug 13, 2024
1 parent 2cdab41 commit 970cc81
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 198 deletions.
7 changes: 7 additions & 0 deletions .changeset/ninety-tips-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
swc_core: patch
swc_html: patch
swc_html_minifier: patch
---

feat(html/minifier): Support using custom css minifier
2 changes: 1 addition & 1 deletion crates/swc_html/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ minifier = ["swc_html_minifier"]
[dependencies]
swc_html_ast = { version = "0.37.0", path = "../swc_html_ast" }
swc_html_codegen = { version = "0.46.0", path = "../swc_html_codegen" }
swc_html_minifier = { version = "0.143.0", path = "../swc_html_minifier", optional = true }
swc_html_minifier = { version = "0.143.0", path = "../swc_html_minifier", optional = true, default-features = false }
swc_html_parser = { version = "0.43.0", path = "../swc_html_parser" }
swc_html_visit = { version = "0.37.0", path = "../swc_html_visit" }
13 changes: 9 additions & 4 deletions crates/swc_html_minifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ version = "0.143.0"
[lib]
bench = false

[features]
default = ["default-css-minifier"]
default-css-minifier = ["swc_css_ast", "swc_css_codegen", "swc_css_minifier", "swc_css_parser"]
custom-css-minifier = []

[dependencies]
once_cell = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Expand All @@ -23,10 +28,10 @@ serde_json = { workspace = true }
swc_atoms = { version = "0.6.5", path = "../swc_atoms" }
swc_cached = { version = "0.3.19", path = "../swc_cached" }
swc_common = { version = "0.37.0", path = "../swc_common" }
swc_css_ast = { version = "0.144.0", path = "../swc_css_ast" }
swc_css_codegen = { version = "0.155.0", path = "../swc_css_codegen" }
swc_css_minifier = { version = "0.120.0", path = "../swc_css_minifier" }
swc_css_parser = { version = "0.154.0", path = "../swc_css_parser" }
swc_css_ast = { version = "0.144.0", path = "../swc_css_ast", optional = true }
swc_css_codegen = { version = "0.155.0", path = "../swc_css_codegen", optional = true }
swc_css_minifier = { version = "0.120.0", path = "../swc_css_minifier", optional = true }
swc_css_parser = { version = "0.154.0", path = "../swc_css_parser", optional = true }
swc_ecma_ast = { version = "0.118.0", path = "../swc_ecma_ast" }
swc_ecma_codegen = { version = "0.155.0", path = "../swc_ecma_codegen", features = [
"serde-impl",
Expand Down
Loading

0 comments on commit 970cc81

Please sign in to comment.