CSS minification using esbuild
This commit is contained in:
parent
ad7a24f9bd
commit
e4d8b14d0b
26 changed files with 187 additions and 63 deletions
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
publish = false
|
||||
name = "minify_html"
|
||||
description = "Fast and smart HTML + JS minifier"
|
||||
description = "Extremely fast and smart HTML + JS + CSS minifier"
|
||||
license = "MIT"
|
||||
homepage = "https://github.com/wilsonzlin/minify-html"
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ use pyo3::exceptions::PySyntaxError;
|
|||
use pyo3::wrap_pyfunction;
|
||||
use std::str::from_utf8_unchecked;
|
||||
|
||||
#[pyfunction(py_args="*", minify_js="false")]
|
||||
fn minify(code: String, minify_js: bool) -> PyResult<String> {
|
||||
#[pyfunction(py_args="*", minify_js="false", minify_css="false")]
|
||||
fn minify(code: String, minify_js: bool, minify_css: bool) -> PyResult<String> {
|
||||
let mut code = code.into_bytes();
|
||||
match minify_html_native(&mut code, &Cfg {
|
||||
minify_js,
|
||||
minify_css,
|
||||
}) {
|
||||
Ok(out_len) => Ok(unsafe { from_utf8_unchecked(&code[0..out_len]).to_string() }),
|
||||
Err(Error { error_type, position }) => Err(PySyntaxError::new_err(format!("{} [Character {}]", error_type.message(), position))),
|
||||
|
|
|
|||
Reference in a new issue