-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd60983
commit c7d0652
Showing
18 changed files
with
79 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ authors = ["Wilson Lin <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
minify-html = { path = "../../../rust/main", features = ["js-esbuild"] } | ||
minify-html = { path = "../../../rust/main" } | ||
serde = { version = "1.0.104", features = ["derive"] } | ||
serde_json = "1.0.44" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ authors = ["Wilson Lin <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
minify-html = { path = "../rust/main", features = ["js-esbuild"] } | ||
minify-html = { path = "../rust/main" } | ||
structopt = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ authors = ["Wilson Lin <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
minify-html = { path = "../rust/main", features = ["js-esbuild"] } | ||
minify-html = { path = "../rust/main" } | ||
jni = "0.14.0" | ||
|
||
[lib] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
#[cfg(feature = "js-esbuild")] | ||
use { | ||
crate::minify::esbuild::minify_using_esbuild, | ||
esbuild_rs::{ | ||
Charset, LegalComments, Loader, SourceMap, TransformOptions, TransformOptionsBuilder, | ||
}, | ||
lazy_static::lazy_static, | ||
std::sync::Arc, | ||
}; | ||
use std::str::from_utf8_unchecked; | ||
|
||
use crate::cfg::Cfg; | ||
use crate::common::whitespace::trimmed; | ||
use css_minify::optimizations::{Level, Minifier}; | ||
|
||
#[cfg(feature = "js-esbuild")] | ||
lazy_static! { | ||
pub static ref MINIFY_CSS_TRANSFORM_OPTIONS: Arc<TransformOptions> = { | ||
let mut builder = TransformOptionsBuilder::new(); | ||
builder.charset = Charset::UTF8; | ||
builder.legal_comments = LegalComments::None; | ||
builder.loader = Loader::CSS; | ||
builder.minify_identifiers = true; | ||
builder.minify_syntax = true; | ||
builder.minify_whitespace = true; | ||
builder.source_map = SourceMap::None; | ||
builder.build() | ||
}; | ||
} | ||
|
||
#[cfg(not(feature = "js-esbuild"))] | ||
pub fn minify_css(_cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) { | ||
out.extend_from_slice(trimmed(code)); | ||
} | ||
|
||
#[cfg(feature = "js-esbuild")] | ||
pub fn minify_css(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) { | ||
if !cfg.minify_css { | ||
out.extend_from_slice(trimmed(code)); | ||
} else { | ||
minify_using_esbuild(out, code, &MINIFY_CSS_TRANSFORM_OPTIONS.clone()); | ||
if cfg.minify_css { | ||
let result = Minifier::default().minify(unsafe { from_utf8_unchecked(code) }, Level::Three); | ||
// TODO Collect error as warning. | ||
if let Ok(min) = result { | ||
if min.len() < code.len() { | ||
out.extend_from_slice(min.as_bytes()); | ||
return; | ||
}; | ||
}; | ||
} | ||
out.extend_from_slice(trimmed(code)); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.