Add support for configuration and JS minification using esbuild
This commit is contained in:
parent
0787bb83f1
commit
ced0e82515
19 changed files with 174 additions and 62 deletions
|
|
@ -1,13 +1,16 @@
|
|||
use hyperbuild::hyperbuild as hyperbuild_native;
|
||||
use hyperbuild::{Cfg, hyperbuild as hyperbuild_native};
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::exceptions::SyntaxError;
|
||||
use pyo3::wrap_pyfunction;
|
||||
use std::str::from_utf8_unchecked;
|
||||
use pyo3::types::PyTuple;
|
||||
|
||||
#[pyfunction]
|
||||
fn minify(code: String) -> PyResult<String> {
|
||||
#[pyfunction(py_args="*", minify_js="false")]
|
||||
fn minify(code: String, minify_js: bool) -> PyResult<String> {
|
||||
let mut code = code.into_bytes();
|
||||
match hyperbuild_native(&mut code) {
|
||||
match hyperbuild_native(&mut code, &Cfg {
|
||||
minify_js,
|
||||
}) {
|
||||
Ok(out_len) => Ok(unsafe { from_utf8_unchecked(&code[0..out_len]).to_string() }),
|
||||
Err((err, pos)) => Err(SyntaxError::py_err(format!("{} [Character {}]", err.message(), pos))),
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue