htmlnano 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -12
- package/dist/_modules/collapseAttributeWhitespace.d.mts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.d.ts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.js +296 -0
- package/dist/_modules/collapseAttributeWhitespace.mjs +293 -0
- package/dist/_modules/collapseBooleanAttributes.d.mts +60 -0
- package/dist/_modules/collapseBooleanAttributes.d.ts +60 -0
- package/dist/_modules/collapseBooleanAttributes.js +159 -0
- package/{lib/modules → dist/_modules}/collapseBooleanAttributes.mjs +39 -57
- package/dist/_modules/collapseWhitespace.d.mts +57 -0
- package/dist/_modules/collapseWhitespace.d.ts +57 -0
- package/dist/_modules/collapseWhitespace.js +172 -0
- package/dist/_modules/collapseWhitespace.mjs +170 -0
- package/dist/_modules/custom.d.mts +57 -0
- package/dist/_modules/custom.d.ts +57 -0
- package/dist/_modules/custom.js +22 -0
- package/dist/_modules/custom.mjs +20 -0
- package/dist/_modules/deduplicateAttributeValues.d.mts +56 -0
- package/dist/_modules/deduplicateAttributeValues.d.ts +56 -0
- package/dist/_modules/deduplicateAttributeValues.js +38 -0
- package/dist/_modules/deduplicateAttributeValues.mjs +36 -0
- package/dist/_modules/example.d.mts +59 -0
- package/dist/_modules/example.d.ts +59 -0
- package/dist/_modules/example.js +67 -0
- package/dist/_modules/example.mjs +65 -0
- package/dist/_modules/mergeScripts.d.mts +56 -0
- package/dist/_modules/mergeScripts.d.ts +56 -0
- package/dist/_modules/mergeScripts.js +53 -0
- package/dist/_modules/mergeScripts.mjs +51 -0
- package/dist/_modules/mergeStyles.d.mts +56 -0
- package/dist/_modules/mergeStyles.d.ts +56 -0
- package/dist/_modules/mergeStyles.js +42 -0
- package/dist/_modules/mergeStyles.mjs +40 -0
- package/dist/_modules/minifyConditionalComments.d.mts +56 -0
- package/dist/_modules/minifyConditionalComments.d.ts +56 -0
- package/dist/_modules/minifyConditionalComments.js +54 -0
- package/{lib/modules → dist/_modules}/minifyConditionalComments.mjs +21 -22
- package/dist/_modules/minifyCss.d.mts +56 -0
- package/dist/_modules/minifyCss.d.ts +56 -0
- package/dist/_modules/minifyCss.js +84 -0
- package/dist/_modules/minifyCss.mjs +82 -0
- package/dist/_modules/minifyJs.d.mts +56 -0
- package/dist/_modules/minifyJs.d.ts +56 -0
- package/dist/_modules/minifyJs.js +108 -0
- package/dist/_modules/minifyJs.mjs +106 -0
- package/dist/_modules/minifyJson.d.mts +56 -0
- package/dist/_modules/minifyJson.d.ts +56 -0
- package/dist/_modules/minifyJson.js +35 -0
- package/dist/_modules/minifyJson.mjs +33 -0
- package/dist/_modules/minifySvg.d.mts +56 -0
- package/dist/_modules/minifySvg.d.ts +56 -0
- package/dist/_modules/minifySvg.js +40 -0
- package/dist/_modules/minifySvg.mjs +38 -0
- package/dist/_modules/minifyUrls.d.mts +56 -0
- package/dist/_modules/minifyUrls.d.ts +56 -0
- package/dist/_modules/minifyUrls.js +180 -0
- package/dist/_modules/minifyUrls.mjs +178 -0
- package/dist/_modules/normalizeAttributeValues.d.mts +56 -0
- package/dist/_modules/normalizeAttributeValues.d.ts +56 -0
- package/dist/_modules/normalizeAttributeValues.js +234 -0
- package/dist/_modules/normalizeAttributeValues.mjs +232 -0
- package/dist/_modules/removeAttributeQuotes.d.mts +56 -0
- package/dist/_modules/removeAttributeQuotes.d.ts +56 -0
- package/dist/_modules/removeAttributeQuotes.js +15 -0
- package/dist/_modules/removeAttributeQuotes.mjs +13 -0
- package/dist/_modules/removeComments.d.mts +58 -0
- package/dist/_modules/removeComments.d.ts +58 -0
- package/dist/_modules/removeComments.js +83 -0
- package/{lib/modules → dist/_modules}/removeComments.mjs +24 -35
- package/dist/_modules/removeEmptyAttributes.d.mts +56 -0
- package/dist/_modules/removeEmptyAttributes.d.ts +56 -0
- package/dist/_modules/removeEmptyAttributes.js +197 -0
- package/dist/_modules/removeEmptyAttributes.mjs +195 -0
- package/dist/_modules/removeOptionalTags.d.mts +56 -0
- package/dist/_modules/removeOptionalTags.d.ts +56 -0
- package/dist/_modules/removeOptionalTags.js +190 -0
- package/{lib/modules → dist/_modules}/removeOptionalTags.mjs +54 -91
- package/dist/_modules/removeRedundantAttributes.d.mts +57 -0
- package/dist/_modules/removeRedundantAttributes.d.ts +57 -0
- package/dist/_modules/removeRedundantAttributes.js +128 -0
- package/{lib/modules → dist/_modules}/removeRedundantAttributes.mjs +43 -59
- package/dist/_modules/removeUnusedCss.d.mts +60 -0
- package/dist/_modules/removeUnusedCss.d.ts +60 -0
- package/dist/_modules/removeUnusedCss.js +134 -0
- package/dist/_modules/removeUnusedCss.mjs +132 -0
- package/dist/_modules/sortAttributes.d.mts +57 -0
- package/dist/_modules/sortAttributes.d.ts +57 -0
- package/dist/_modules/sortAttributes.js +102 -0
- package/{lib/modules → dist/_modules}/sortAttributes.mjs +39 -58
- package/dist/_modules/sortAttributesWithLists.d.mts +56 -0
- package/dist/_modules/sortAttributesWithLists.d.ts +56 -0
- package/dist/_modules/sortAttributesWithLists.js +118 -0
- package/{lib/modules → dist/_modules}/sortAttributesWithLists.mjs +41 -59
- package/dist/helpers.d.ts +16 -0
- package/dist/helpers.js +72 -0
- package/dist/helpers.mjs +63 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +223 -0
- package/dist/index.mjs +209 -0
- package/dist/presets/ampSafe.d.ts +47 -0
- package/dist/presets/ampSafe.js +19 -0
- package/{lib → dist}/presets/ampSafe.mjs +6 -4
- package/dist/presets/max.d.ts +47 -0
- package/dist/presets/max.js +28 -0
- package/{lib → dist}/presets/max.mjs +6 -4
- package/dist/presets/safe.d.ts +47 -0
- package/dist/presets/safe.js +60 -0
- package/{lib → dist}/presets/safe.mjs +13 -20
- package/package.json +53 -56
- package/.eslintignore +0 -3
- package/CHANGELOG.md +0 -409
- package/docs/README.md +0 -33
- package/docs/babel.config.js +0 -3
- package/docs/docs/010-introduction.md +0 -22
- package/docs/docs/020-usage.md +0 -117
- package/docs/docs/030-config.md +0 -21
- package/docs/docs/040-presets.md +0 -75
- package/docs/docs/050-modules.md +0 -855
- package/docs/docs/060-contribute.md +0 -16
- package/docs/docusaurus.config.js +0 -65
- package/docs/netlify.toml +0 -4
- package/docs/package-lock.json +0 -21630
- package/docs/package.json +0 -40
- package/docs/sidebars.js +0 -26
- package/docs/versioned_docs/version-1.1.1/010-introduction.md +0 -22
- package/docs/versioned_docs/version-1.1.1/020-usage.md +0 -77
- package/docs/versioned_docs/version-1.1.1/030-config.md +0 -21
- package/docs/versioned_docs/version-1.1.1/040-presets.md +0 -75
- package/docs/versioned_docs/version-1.1.1/050-modules.md +0 -785
- package/docs/versioned_docs/version-1.1.1/060-contribute.md +0 -16
- package/docs/versioned_docs/version-2.0.0/010-introduction.md +0 -22
- package/docs/versioned_docs/version-2.0.0/020-usage.md +0 -77
- package/docs/versioned_docs/version-2.0.0/030-config.md +0 -21
- package/docs/versioned_docs/version-2.0.0/040-presets.md +0 -75
- package/docs/versioned_docs/version-2.0.0/050-modules.md +0 -838
- package/docs/versioned_docs/version-2.0.0/060-contribute.md +0 -16
- package/docs/versioned_sidebars/version-1.1.1-sidebars.json +0 -8
- package/docs/versioned_sidebars/version-2.0.0-sidebars.json +0 -8
- package/docs/versions.json +0 -4
- package/index.cjs +0 -11
- package/index.d.cts +0 -3
- package/index.d.mts +0 -3
- package/index.d.ts +0 -94
- package/index.mjs +0 -2
- package/lib/helpers.cjs +0 -79
- package/lib/helpers.mjs +0 -53
- package/lib/htmlnano.cjs +0 -202
- package/lib/htmlnano.mjs +0 -198
- package/lib/modules/collapseAttributeWhitespace.cjs +0 -86
- package/lib/modules/collapseAttributeWhitespace.mjs +0 -104
- package/lib/modules/collapseBooleanAttributes.cjs +0 -62
- package/lib/modules/collapseWhitespace.cjs +0 -100
- package/lib/modules/collapseWhitespace.mjs +0 -132
- package/lib/modules/custom.cjs +0 -19
- package/lib/modules/custom.mjs +0 -16
- package/lib/modules/deduplicateAttributeValues.cjs +0 -38
- package/lib/modules/deduplicateAttributeValues.mjs +0 -40
- package/lib/modules/example.cjs +0 -85
- package/lib/modules/example.mjs +0 -75
- package/lib/modules/mergeScripts.cjs +0 -54
- package/lib/modules/mergeScripts.mjs +0 -56
- package/lib/modules/mergeStyles.cjs +0 -38
- package/lib/modules/mergeStyles.mjs +0 -36
- package/lib/modules/minifyConditionalComments.cjs +0 -47
- package/lib/modules/minifyCss.cjs +0 -73
- package/lib/modules/minifyCss.mjs +0 -88
- package/lib/modules/minifyJs.cjs +0 -103
- package/lib/modules/minifyJs.mjs +0 -121
- package/lib/modules/minifyJson.cjs +0 -24
- package/lib/modules/minifyJson.mjs +0 -21
- package/lib/modules/minifySvg.cjs +0 -37
- package/lib/modules/minifySvg.mjs +0 -30
- package/lib/modules/minifyUrls.cjs +0 -141
- package/lib/modules/minifyUrls.mjs +0 -229
- package/lib/modules/normalizeAttributeValues.cjs +0 -120
- package/lib/modules/normalizeAttributeValues.mjs +0 -140
- package/lib/modules/removeAttributeQuotes.cjs +0 -17
- package/lib/modules/removeAttributeQuotes.mjs +0 -12
- package/lib/modules/removeComments.cjs +0 -86
- package/lib/modules/removeEmptyAttributes.cjs +0 -72
- package/lib/modules/removeEmptyAttributes.mjs +0 -121
- package/lib/modules/removeOptionalTags.cjs +0 -183
- package/lib/modules/removeRedundantAttributes.cjs +0 -112
- package/lib/modules/removeUnusedCss.cjs +0 -113
- package/lib/modules/removeUnusedCss.mjs +0 -122
- package/lib/modules/sortAttributes.cjs +0 -98
- package/lib/modules/sortAttributesWithLists.cjs +0 -114
- package/lib/presets/ampSafe.cjs +0 -18
- package/lib/presets/max.cjs +0 -27
- package/lib/presets/safe.cjs +0 -65
- package/test.js +0 -23
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
interface HtmlnanoOptions {
|
|
15
|
+
skipConfigLoading?: boolean;
|
|
16
|
+
skipInternalWarnings?: boolean;
|
|
17
|
+
collapseAttributeWhitespace?: boolean;
|
|
18
|
+
collapseBooleanAttributes?: {
|
|
19
|
+
amphtml?: boolean;
|
|
20
|
+
};
|
|
21
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
22
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
23
|
+
deduplicateAttributeValues?: boolean;
|
|
24
|
+
minifyUrls?: URL | string | false;
|
|
25
|
+
mergeStyles?: boolean;
|
|
26
|
+
mergeScripts?: boolean;
|
|
27
|
+
minifyCss?: Options | boolean;
|
|
28
|
+
minifyConditionalComments?: boolean;
|
|
29
|
+
minifyJs?: MinifyOptions | boolean;
|
|
30
|
+
minifyJson?: boolean;
|
|
31
|
+
minifySvg?: Config | boolean;
|
|
32
|
+
normalizeAttributeValues?: boolean;
|
|
33
|
+
removeAttributeQuotes?: boolean;
|
|
34
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
35
|
+
removeEmptyAttributes?: boolean;
|
|
36
|
+
removeRedundantAttributes?: boolean;
|
|
37
|
+
removeOptionalTags?: boolean;
|
|
38
|
+
removeUnusedCss?: boolean;
|
|
39
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
40
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
}
|
|
42
|
+
interface HtmlnanoPreset extends Omit<HtmlnanoOptions, 'skipConfigLoading'> {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const _default: HtmlnanoPreset;
|
|
46
|
+
|
|
47
|
+
export { _default as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var safePreset = require('./safe.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var safePreset__default = /*#__PURE__*/_interopDefault(safePreset);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A safe preset for AMP pages (https://www.ampproject.org)
|
|
11
|
+
*/ var ampSafe = {
|
|
12
|
+
...safePreset__default.default,
|
|
13
|
+
collapseBooleanAttributes: {
|
|
14
|
+
amphtml: true
|
|
15
|
+
},
|
|
16
|
+
minifyJs: false
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.default = ampSafe;
|
|
@@ -2,10 +2,12 @@ import safePreset from './safe.mjs';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A safe preset for AMP pages (https://www.ampproject.org)
|
|
5
|
-
*/
|
|
6
|
-
|
|
5
|
+
*/ var ampSafe = {
|
|
6
|
+
...safePreset,
|
|
7
7
|
collapseBooleanAttributes: {
|
|
8
|
-
amphtml: true
|
|
8
|
+
amphtml: true
|
|
9
9
|
},
|
|
10
|
-
minifyJs: false
|
|
10
|
+
minifyJs: false
|
|
11
11
|
};
|
|
12
|
+
|
|
13
|
+
export { ampSafe as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
interface HtmlnanoOptions {
|
|
15
|
+
skipConfigLoading?: boolean;
|
|
16
|
+
skipInternalWarnings?: boolean;
|
|
17
|
+
collapseAttributeWhitespace?: boolean;
|
|
18
|
+
collapseBooleanAttributes?: {
|
|
19
|
+
amphtml?: boolean;
|
|
20
|
+
};
|
|
21
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
22
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
23
|
+
deduplicateAttributeValues?: boolean;
|
|
24
|
+
minifyUrls?: URL | string | false;
|
|
25
|
+
mergeStyles?: boolean;
|
|
26
|
+
mergeScripts?: boolean;
|
|
27
|
+
minifyCss?: Options | boolean;
|
|
28
|
+
minifyConditionalComments?: boolean;
|
|
29
|
+
minifyJs?: MinifyOptions | boolean;
|
|
30
|
+
minifyJson?: boolean;
|
|
31
|
+
minifySvg?: Config | boolean;
|
|
32
|
+
normalizeAttributeValues?: boolean;
|
|
33
|
+
removeAttributeQuotes?: boolean;
|
|
34
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
35
|
+
removeEmptyAttributes?: boolean;
|
|
36
|
+
removeRedundantAttributes?: boolean;
|
|
37
|
+
removeOptionalTags?: boolean;
|
|
38
|
+
removeUnusedCss?: boolean;
|
|
39
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
40
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
}
|
|
42
|
+
interface HtmlnanoPreset extends Omit<HtmlnanoOptions, 'skipConfigLoading'> {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const _default: HtmlnanoPreset;
|
|
46
|
+
|
|
47
|
+
export { _default as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var safePreset = require('./safe.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var safePreset__default = /*#__PURE__*/_interopDefault(safePreset);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Maximal minification (might break some pages)
|
|
11
|
+
*/ var max = {
|
|
12
|
+
...safePreset__default.default,
|
|
13
|
+
collapseWhitespace: 'all',
|
|
14
|
+
removeComments: 'all',
|
|
15
|
+
removeAttributeQuotes: true,
|
|
16
|
+
removeRedundantAttributes: true,
|
|
17
|
+
mergeScripts: true,
|
|
18
|
+
mergeStyles: true,
|
|
19
|
+
removeUnusedCss: {},
|
|
20
|
+
minifyCss: {
|
|
21
|
+
preset: 'default'
|
|
22
|
+
},
|
|
23
|
+
minifySvg: {},
|
|
24
|
+
minifyConditionalComments: true,
|
|
25
|
+
removeOptionalTags: true
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.default = max;
|
|
@@ -2,8 +2,8 @@ import safePreset from './safe.mjs';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Maximal minification (might break some pages)
|
|
5
|
-
*/
|
|
6
|
-
|
|
5
|
+
*/ var max = {
|
|
6
|
+
...safePreset,
|
|
7
7
|
collapseWhitespace: 'all',
|
|
8
8
|
removeComments: 'all',
|
|
9
9
|
removeAttributeQuotes: true,
|
|
@@ -12,9 +12,11 @@ export default { ...safePreset,
|
|
|
12
12
|
mergeStyles: true,
|
|
13
13
|
removeUnusedCss: {},
|
|
14
14
|
minifyCss: {
|
|
15
|
-
preset: 'default'
|
|
15
|
+
preset: 'default'
|
|
16
16
|
},
|
|
17
17
|
minifySvg: {},
|
|
18
18
|
minifyConditionalComments: true,
|
|
19
|
-
removeOptionalTags: true
|
|
19
|
+
removeOptionalTags: true
|
|
20
20
|
};
|
|
21
|
+
|
|
22
|
+
export { max as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
interface HtmlnanoOptions {
|
|
15
|
+
skipConfigLoading?: boolean;
|
|
16
|
+
skipInternalWarnings?: boolean;
|
|
17
|
+
collapseAttributeWhitespace?: boolean;
|
|
18
|
+
collapseBooleanAttributes?: {
|
|
19
|
+
amphtml?: boolean;
|
|
20
|
+
};
|
|
21
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
22
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
23
|
+
deduplicateAttributeValues?: boolean;
|
|
24
|
+
minifyUrls?: URL | string | false;
|
|
25
|
+
mergeStyles?: boolean;
|
|
26
|
+
mergeScripts?: boolean;
|
|
27
|
+
minifyCss?: Options | boolean;
|
|
28
|
+
minifyConditionalComments?: boolean;
|
|
29
|
+
minifyJs?: MinifyOptions | boolean;
|
|
30
|
+
minifyJson?: boolean;
|
|
31
|
+
minifySvg?: Config | boolean;
|
|
32
|
+
normalizeAttributeValues?: boolean;
|
|
33
|
+
removeAttributeQuotes?: boolean;
|
|
34
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
35
|
+
removeEmptyAttributes?: boolean;
|
|
36
|
+
removeRedundantAttributes?: boolean;
|
|
37
|
+
removeOptionalTags?: boolean;
|
|
38
|
+
removeUnusedCss?: boolean;
|
|
39
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
40
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
}
|
|
42
|
+
interface HtmlnanoPreset extends Omit<HtmlnanoOptions, 'skipConfigLoading'> {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const _default: HtmlnanoPreset;
|
|
46
|
+
|
|
47
|
+
export { _default as default };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minify HTML in a safe way without breaking anything.
|
|
5
|
+
*/ var safe = {
|
|
6
|
+
/* ----------------------------------------
|
|
7
|
+
* Attributes
|
|
8
|
+
* ---------------------------------------- */ // normalize the case of attribute names and values
|
|
9
|
+
// normalizeAttributeValues will also normalize property value with invalid value default
|
|
10
|
+
// See https://html.spec.whatwg.org/#invalid-value-default
|
|
11
|
+
normalizeAttributeValues: true,
|
|
12
|
+
removeEmptyAttributes: true,
|
|
13
|
+
collapseAttributeWhitespace: true,
|
|
14
|
+
// removeRedundantAttributes will remove attributes when missing value default matches the attribute's value
|
|
15
|
+
// See https://html.spec.whatwg.org/#missing-value-default
|
|
16
|
+
removeRedundantAttributes: false,
|
|
17
|
+
// collapseBooleanAttributes will also collapse those default state can be omitted
|
|
18
|
+
collapseBooleanAttributes: {
|
|
19
|
+
amphtml: false
|
|
20
|
+
},
|
|
21
|
+
deduplicateAttributeValues: true,
|
|
22
|
+
minifyUrls: false,
|
|
23
|
+
sortAttributes: false,
|
|
24
|
+
sortAttributesWithLists: 'alphabetical',
|
|
25
|
+
/* ----------------------------------------
|
|
26
|
+
* Minify HTML content
|
|
27
|
+
* ---------------------------------------- */ collapseWhitespace: 'conservative',
|
|
28
|
+
removeComments: 'safe',
|
|
29
|
+
minifyConditionalComments: false,
|
|
30
|
+
removeOptionalTags: false,
|
|
31
|
+
removeAttributeQuotes: false,
|
|
32
|
+
/* ----------------------------------------
|
|
33
|
+
* Minify inline <style>, <script> and <svg> tag
|
|
34
|
+
* ---------------------------------------- */ mergeStyles: false,
|
|
35
|
+
mergeScripts: false,
|
|
36
|
+
minifyCss: {
|
|
37
|
+
preset: 'default'
|
|
38
|
+
},
|
|
39
|
+
minifyJs: {},
|
|
40
|
+
minifyJson: {},
|
|
41
|
+
minifySvg: {
|
|
42
|
+
plugins: [
|
|
43
|
+
{
|
|
44
|
+
name: 'preset-default',
|
|
45
|
+
params: {
|
|
46
|
+
overrides: {
|
|
47
|
+
collapseGroups: false,
|
|
48
|
+
convertShapeToPath: false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
removeUnusedCss: false,
|
|
55
|
+
/* ----------------------------------------
|
|
56
|
+
* Miscellaneous
|
|
57
|
+
* ---------------------------------------- */ custom: (tree, _options)=>tree
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.default = safe;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Minify HTML in a safe way without breaking anything.
|
|
3
|
-
*/
|
|
4
|
-
export default {
|
|
3
|
+
*/ var safe = {
|
|
5
4
|
/* ----------------------------------------
|
|
6
5
|
* Attributes
|
|
7
|
-
* ---------------------------------------- */
|
|
8
|
-
// normalize the case of attribute names and values
|
|
6
|
+
* ---------------------------------------- */ // normalize the case of attribute names and values
|
|
9
7
|
// normalizeAttributeValues will also normalize property value with invalid value default
|
|
10
8
|
// See https://html.spec.whatwg.org/#invalid-value-default
|
|
11
9
|
normalizeAttributeValues: true,
|
|
@@ -16,30 +14,25 @@ export default {
|
|
|
16
14
|
removeRedundantAttributes: false,
|
|
17
15
|
// collapseBooleanAttributes will also collapse those default state can be omitted
|
|
18
16
|
collapseBooleanAttributes: {
|
|
19
|
-
amphtml: false
|
|
17
|
+
amphtml: false
|
|
20
18
|
},
|
|
21
19
|
deduplicateAttributeValues: true,
|
|
22
|
-
|
|
23
20
|
minifyUrls: false,
|
|
24
|
-
|
|
25
21
|
sortAttributes: false,
|
|
26
22
|
sortAttributesWithLists: 'alphabetical',
|
|
27
|
-
|
|
28
23
|
/* ----------------------------------------
|
|
29
24
|
* Minify HTML content
|
|
30
|
-
* ---------------------------------------- */
|
|
31
|
-
collapseWhitespace: 'conservative',
|
|
25
|
+
* ---------------------------------------- */ collapseWhitespace: 'conservative',
|
|
32
26
|
removeComments: 'safe',
|
|
33
27
|
minifyConditionalComments: false,
|
|
34
28
|
removeOptionalTags: false,
|
|
35
29
|
removeAttributeQuotes: false,
|
|
36
30
|
/* ----------------------------------------
|
|
37
31
|
* Minify inline <style>, <script> and <svg> tag
|
|
38
|
-
* ---------------------------------------- */
|
|
39
|
-
mergeStyles: false,
|
|
32
|
+
* ---------------------------------------- */ mergeStyles: false,
|
|
40
33
|
mergeScripts: false,
|
|
41
34
|
minifyCss: {
|
|
42
|
-
preset: 'default'
|
|
35
|
+
preset: 'default'
|
|
43
36
|
},
|
|
44
37
|
minifyJs: {},
|
|
45
38
|
minifyJson: {},
|
|
@@ -50,16 +43,16 @@ export default {
|
|
|
50
43
|
params: {
|
|
51
44
|
overrides: {
|
|
52
45
|
collapseGroups: false,
|
|
53
|
-
convertShapeToPath: false
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
46
|
+
convertShapeToPath: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
57
50
|
]
|
|
58
51
|
},
|
|
59
52
|
removeUnusedCss: false,
|
|
60
|
-
|
|
61
53
|
/* ----------------------------------------
|
|
62
54
|
* Miscellaneous
|
|
63
|
-
* ---------------------------------------- */
|
|
64
|
-
custom: []
|
|
55
|
+
* ---------------------------------------- */ custom: (tree, _options)=>tree
|
|
65
56
|
};
|
|
57
|
+
|
|
58
|
+
export { safe as default };
|
package/package.json
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htmlnano",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Modular HTML minifier, built on top of the PostHTML",
|
|
5
|
-
"main": "index.cjs",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"source": "index.mjs",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./index.d.ts",
|
|
11
|
-
"require": "./index.cjs",
|
|
12
|
-
"import": "./index.mjs"
|
|
13
|
-
},
|
|
14
|
-
"./index.mjs": {
|
|
15
|
-
"types": "./index.d.mts",
|
|
16
|
-
"import": "./index.mjs"
|
|
17
|
-
},
|
|
18
|
-
"./index.cjs": {
|
|
19
|
-
"types": "./index.d.cts",
|
|
20
|
-
"require": "./index.cjs"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"types": "index.d.ts",
|
|
24
5
|
"author": "Kirill Maltsev <maltsevkirill@gmail.com>",
|
|
25
6
|
"license": "MIT",
|
|
26
7
|
"scripts": {
|
|
27
|
-
"clean": "rimraf
|
|
28
|
-
"
|
|
29
|
-
"
|
|
8
|
+
"clean": "rimraf dist",
|
|
9
|
+
"build": "npm run clean && bunchee",
|
|
10
|
+
"compile": "npm run build",
|
|
11
|
+
"lint": "eslint --fix .",
|
|
30
12
|
"pretest": "npm run lint && npm run compile",
|
|
31
13
|
"test": ":",
|
|
32
|
-
"posttest": "mocha --timeout 5000 --require @
|
|
14
|
+
"posttest": "mocha --timeout 5000 --require @swc-node/register --recursive --check-leaks --globals addresses",
|
|
33
15
|
"prepare": "npm run compile"
|
|
34
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.mjs",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./helpers": {
|
|
24
|
+
"types": "./dist/helpers.d.ts",
|
|
25
|
+
"import": "./dist/helpers.mjs",
|
|
26
|
+
"require": "./dist/helpers.js"
|
|
27
|
+
},
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.mjs",
|
|
31
|
+
"require": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./presets/ampSafe": {
|
|
34
|
+
"types": "./dist/presets/ampSafe.d.ts",
|
|
35
|
+
"import": "./dist/presets/ampSafe.mjs",
|
|
36
|
+
"require": "./dist/presets/ampSafe.js"
|
|
37
|
+
},
|
|
38
|
+
"./presets/max": {
|
|
39
|
+
"types": "./dist/presets/max.d.ts",
|
|
40
|
+
"import": "./dist/presets/max.mjs",
|
|
41
|
+
"require": "./dist/presets/max.js"
|
|
42
|
+
},
|
|
43
|
+
"./presets/safe": {
|
|
44
|
+
"types": "./dist/presets/safe.d.ts",
|
|
45
|
+
"import": "./dist/presets/safe.mjs",
|
|
46
|
+
"require": "./dist/presets/safe.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
35
49
|
"keywords": [
|
|
36
50
|
"posthtml",
|
|
37
51
|
"posthtml-plugin",
|
|
@@ -39,44 +53,24 @@
|
|
|
39
53
|
"postproccessor",
|
|
40
54
|
"minifier"
|
|
41
55
|
],
|
|
42
|
-
"babel": {
|
|
43
|
-
"presets": [
|
|
44
|
-
[
|
|
45
|
-
"@babel/env",
|
|
46
|
-
{
|
|
47
|
-
"targets": {
|
|
48
|
-
"node": 10
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
],
|
|
53
|
-
"plugins": [
|
|
54
|
-
[
|
|
55
|
-
"@aminya/babel-plugin-replace-import-extension",
|
|
56
|
-
{
|
|
57
|
-
"extMapping": {
|
|
58
|
-
".mjs": ".cjs"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
56
|
"dependencies": {
|
|
57
|
+
"@types/relateurl": "^0.2.33",
|
|
65
58
|
"cosmiconfig": "^9.0.0",
|
|
66
59
|
"posthtml": "^0.16.5"
|
|
67
60
|
},
|
|
68
61
|
"devDependencies": {
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"
|
|
73
|
-
"@babel/preset-env": "^7.15.6",
|
|
74
|
-
"@babel/register": "^7.15.3",
|
|
62
|
+
"@stylistic/eslint-plugin": "^5.3.1",
|
|
63
|
+
"@swc-node/register": "^1.10.10",
|
|
64
|
+
"@types/node": "^24.0.0",
|
|
65
|
+
"bunchee": "^6.5.1",
|
|
75
66
|
"cssnano": "^7.0.0",
|
|
76
|
-
"eslint": "^
|
|
67
|
+
"eslint": "^9.25.1",
|
|
68
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
|
77
69
|
"eslint-plugin-import": "^2.28.1",
|
|
78
|
-
"eslint-plugin-
|
|
79
|
-
"
|
|
70
|
+
"eslint-plugin-import-x": "^4.11.0",
|
|
71
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
72
|
+
"expect": "^30.1.1",
|
|
73
|
+
"globals": "^16.0.0",
|
|
80
74
|
"mocha": "^11.0.1",
|
|
81
75
|
"postcss": "^8.3.11",
|
|
82
76
|
"purgecss": "^7.0.2",
|
|
@@ -85,6 +79,8 @@
|
|
|
85
79
|
"srcset": "5.0.1",
|
|
86
80
|
"svgo": "^3.0.2",
|
|
87
81
|
"terser": "^5.21.0",
|
|
82
|
+
"typescript": "^5.8.3",
|
|
83
|
+
"typescript-eslint": "^8.31.1",
|
|
88
84
|
"uncss": "^0.17.3"
|
|
89
85
|
},
|
|
90
86
|
"peerDependencies": {
|
|
@@ -130,5 +126,6 @@
|
|
|
130
126
|
"bugs": {
|
|
131
127
|
"url": "https://github.com/posthtml/htmlnano/issues"
|
|
132
128
|
},
|
|
133
|
-
"homepage": "https://github.com/posthtml/htmlnano"
|
|
129
|
+
"homepage": "https://github.com/posthtml/htmlnano",
|
|
130
|
+
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
|
|
134
131
|
}
|
package/.eslintignore
DELETED