UNPKG

7.3 kBTypeScriptView Raw
1// Type definitions for html-minifier 4.0
2// Project: https://github.com/kangax/html-minifier, https://kangax.github.io/html-minifier
3// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
4// Riku <https://github.com/rikuayanokozy>
5// Piotr Błażejewicz <https://github.com/peterblazejewicz>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
8import * as UglifyJS from 'uglify-js';
9import * as CleanCSS from 'clean-css';
10import * as RelateUrl from 'relateurl';
11
12export function minify(text: string, options?: Options): string;
13
14export interface Options {
15 // Treat attributes in case sensitive manner (useful for custom HTML tags)
16 caseSensitive?: boolean | undefined;
17
18 // Omit attribute values from boolean attributes
19 collapseBooleanAttributes?: boolean | undefined;
20
21 // Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace=true
22 collapseInlineTagWhitespace?: boolean | undefined;
23
24 /**
25 * Collapse white space that contributes to text nodes in a document tree
26 * @see http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace
27 */
28 collapseWhitespace?: boolean | undefined;
29
30 // Always collapse to 1 space (never remove it entirely). Must be used in conjunction with collapseWhitespace=true
31 conservativeCollapse?: boolean | undefined;
32 /**
33 * Handle parse errors instead of aborting
34 * @default false
35 */
36 continueOnParseError?: boolean | undefined;
37
38 // Arrays of regex'es that allow to support custom attribute assign expressions (e.g. '<div flex?="{{mode != cover}}"></div>')
39 customAttrAssign?: RegExp[] | undefined;
40
41 // Regex that specifies custom attribute to strip newlines from (e.g. /ng-class/)
42 customAttrCollapse?: RegExp | undefined;
43
44 // Arrays of regex'es that allow to support custom attribute surround expressions (e.g. <input {{#if value}}checked="checked"{{/if}}>)
45 customAttrSurround?: RegExp[] | undefined;
46
47 // Arrays of regex'es that allow to support custom event attributes for minifyJS (e.g. ng-click)
48 customEventAttributes?: RegExp[] | undefined;
49
50 // Use direct Unicode characters whenever possible
51 decodeEntities?: boolean | undefined;
52
53 // Parse input according to HTML5 specifications
54 html5?: boolean | undefined;
55
56 // Array of regex'es that allow to ignore certain comments, when matched
57 ignoreCustomComments?: RegExp[] | undefined;
58
59 // Array of regex'es that allow to ignore certain fragments, when matched (e.g. <?php ... ?>, {{ ... }}, etc.)
60 ignoreCustomFragments?: RegExp[] | undefined;
61
62 // Insert tags generated by HTML parser
63 includeAutoGeneratedTags?: boolean | undefined;
64
65 // Keep the trailing slash on singleton elements
66 keepClosingSlash?: boolean | undefined;
67
68 // Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
69 maxLineLength?: number | undefined;
70
71 // Minify CSS in style elements and style attributes (uses clean-css or function specified)
72 minifyCSS?: boolean | CleanCSS.Options | ((text: string) => string) | undefined;
73
74 // Minify JavaScript in script elements and event attributes (uses UglifyJS or function specified)
75 minifyJS?: boolean | UglifyJS.MinifyOptions | ((text: string, inline: boolean) => string) | undefined;
76
77 // Minify URLs in various attributes (uses relateurl or function specified)
78 minifyURLs?: boolean | RelateUrl.Options | ((text: string) => string) | undefined;
79
80 // Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with collapseWhitespace=true
81 preserveLineBreaks?: boolean | undefined;
82
83 // Prevents the escaping of the values of attributes
84 preventAttributesEscaping?: boolean | undefined;
85
86 // Process contents of conditional comments through minifier
87 processConditionalComments?: boolean | undefined;
88
89 // Array of strings corresponding to types of script elements to process through minifier (e.g. text/ng-template, text/x-handlebars-template, etc.)
90 processScripts?: string[] | undefined;
91
92 // Type of quote to use for attribute values (' or ")
93 quoteCharacter?: string | undefined;
94
95 /**
96 * Remove quotes around attributes when possible
97 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes
98 */
99 removeAttributeQuotes?: boolean | undefined;
100
101 /**
102 * Strip HTML comments
103 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments
104 */
105 removeComments?: boolean | undefined;
106
107 /**
108 * Remove all attributes with whitespace-only values
109 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes
110 */
111 removeEmptyAttributes?: boolean | ((attrName: string, tag: string) => boolean) | undefined;
112
113 /**
114 * Remove all elements with empty contents
115 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements
116 */
117 removeEmptyElements?: boolean | undefined;
118
119 /**
120 * Remove optional tags
121 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags
122 */
123 removeOptionalTags?: boolean | undefined;
124
125 /**
126 * Remove attributes when value matches default.
127 * @see http://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes
128 */
129 removeRedundantAttributes?: boolean | undefined;
130
131 // Remove type="text/javascript" from script tags. Other type attribute values are left intact
132 removeScriptTypeAttributes?: boolean | undefined;
133
134 // Remove type="text/css" from style and link tags. Other type attribute values are left intact
135 removeStyleLinkTypeAttributes?: boolean | undefined;
136
137 // Remove space between attributes whenever possible. Note that this will result in invalid HTML!
138 removeTagWhitespace?: boolean | undefined;
139
140 /**
141 * Sort attributes by frequency
142 *
143 * Minifier options like sortAttributes and sortClassName won't impact the plain-text size
144 * of the output. However, they form long repetitive chains of characters that should improve
145 * compression ratio of gzip used in HTTP compression.
146 *
147 * @see https://github.com/kangax/html-minifier#sorting-attributes--style-classes
148 */
149 sortAttributes?: boolean | undefined;
150
151 /**
152 * Sort style classes by frequency
153 *
154 * Minifier options like sortAttributes and sortClassName won't impact the plain-text size
155 * of the output. However, they form long repetitive chains of characters that should improve
156 * compression ratio of gzip used in HTTP compression.
157 *
158 * @see https://github.com/kangax/html-minifier#sorting-attributes--style-classes
159 */
160 sortClassName?: boolean | undefined;
161
162 // Trim white space around ignoreCustomFragments
163 trimCustomFragments?: boolean | undefined;
164
165 /**
166 * Replaces the doctype with the short (HTML5) doctype
167 * @see http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype
168 */
169 useShortDoctype?: boolean | undefined;
170}
171
\No newline at end of file