2020-08-25 23:48:42 -04:00
export type Cfg = { __doNotUseCfgDirectly : string & { __itIsANapiExternalValue : never } } ;
/ * *
* Creates configuration that can be passed to minification functions to change the minification approach .
* The value returned is an [ external ] ( https : //nodejs.org/api/n-api.html#n_api_napi_create_external) value with typeof `object` and prototype `null`; it does not have any properties, and should only be used as arguments to minify functions.
*
* @param options - Configurable minifier settings to use when this configuration is passed to a minify function
* @returns An opaque value that can be passed to minify functions
* /
export function createConfiguration ( options : {
2021-08-10 03:45:37 -04:00
/** Do not minify DOCTYPEs. Minified DOCTYPEs may not be spec compliant. */
do_not_minify_doctype? : boolean ,
2021-08-07 11:45:25 -04:00
/** Ensure all unquoted attribute values in the output do not contain any characters prohibited by the WHATWG specification. */
ensure_spec_compliant_unquoted_attribute_values? : boolean ;
2021-08-07 06:02:20 -04:00
/** Do not omit closing tags when possible. */
keep_closing_tags? : boolean ;
/** Do not omit `<html>` and `<head>` opening tags when they don't have attributes. */
keep_html_and_head_opening_tags? : boolean ;
/** Keep spaces between attributes when possible to conform to HTML standards. */
keep_spaces_between_attributes? : boolean ;
/** Keep all comments. */
keep_comments? : boolean ;
2020-08-25 23:48:42 -04:00
/ * *
* If enabled , content in ` <script> ` tags with a JS or no [ MIME type ] ( https : //mimesniff.spec.whatwg.org/#javascript-mime-type) will be minified using [esbuild-rs](https://github.com/wilsonzlin/esbuild-rs).
* /
2021-10-23 02:42:26 -04:00
minify_js? : boolean ;
2021-01-07 08:26:02 -05:00
/ * *
* If enabled , CSS in ` <style> ` tags will be minified using [ esbuild - rs ] ( https : //github.com/wilsonzlin/esbuild-rs).
* /
2021-10-23 02:42:26 -04:00
minify_css? : boolean ;
2021-08-07 06:02:20 -04:00
/** Remove all bangs. */
remove_bangs? : boolean ;
/** Remove all processing_instructions. */
remove_processing_instructions? : boolean ;
2020-08-25 23:48:42 -04:00
} ) : Cfg ;
/ * *
* Minifies a string containing HTML code .
*
* @param src - Source HTML code
* @param cfg - Configuration created by { @link createConfiguration }
* @returns Minified HTML code
* /
2021-08-07 08:32:15 -04:00
export function minify ( src : string | Buffer , cfg : Cfg ) : Buffer ;