htmlnano 2.0.3 → 2.1.0
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/.eslintignore +3 -2
- package/CHANGELOG.md +43 -3
- package/docs/docs/040-presets.md +4 -4
- package/docs/docs/050-modules.md +1 -1
- package/docs/docs/060-contribute.md +1 -1
- package/docs/docusaurus.config.js +5 -0
- package/docs/package-lock.json +7592 -11615
- package/docs/package.json +4 -3
- package/docs/versioned_docs/version-1.1.1/040-presets.md +4 -4
- package/docs/versioned_docs/version-1.1.1/050-modules.md +1 -2
- package/docs/versioned_docs/version-1.1.1/060-contribute.md +1 -1
- package/docs/versioned_docs/version-2.0.0/040-presets.md +4 -4
- package/docs/versioned_docs/version-2.0.0/050-modules.md +1 -1
- package/docs/versioned_docs/version-2.0.0/060-contribute.md +1 -1
- package/index.cjs +11 -0
- package/index.d.cts +3 -0
- package/index.d.mts +3 -0
- package/index.d.ts +3 -3
- package/index.mjs +2 -0
- package/lib/helpers.cjs +78 -0
- package/lib/helpers.mjs +52 -0
- package/lib/htmlnano.cjs +200 -0
- package/lib/htmlnano.mjs +196 -0
- package/lib/modules/{collapseAttributeWhitespace.js → collapseAttributeWhitespace.cjs} +2 -3
- package/lib/modules/collapseAttributeWhitespace.mjs +104 -0
- package/lib/modules/collapseBooleanAttributes.mjs +175 -0
- package/lib/modules/{collapseWhitespace.js → collapseWhitespace.cjs} +3 -2
- package/lib/modules/collapseWhitespace.mjs +132 -0
- package/lib/modules/custom.mjs +16 -0
- package/lib/modules/{deduplicateAttributeValues.js → deduplicateAttributeValues.cjs} +1 -1
- package/lib/modules/deduplicateAttributeValues.mjs +40 -0
- package/lib/modules/example.cjs +85 -0
- package/lib/modules/example.mjs +75 -0
- package/lib/modules/{mergeScripts.js → mergeScripts.cjs} +3 -1
- package/lib/modules/mergeScripts.mjs +56 -0
- package/lib/modules/{mergeStyles.js → mergeStyles.cjs} +4 -2
- package/lib/modules/mergeStyles.mjs +36 -0
- package/lib/modules/{minifyConditionalComments.js → minifyConditionalComments.cjs} +2 -2
- package/lib/modules/minifyConditionalComments.mjs +49 -0
- package/lib/modules/{minifyCss.js → minifyCss.cjs} +12 -8
- package/lib/modules/minifyCss.mjs +88 -0
- package/lib/modules/{minifyJs.js → minifyJs.cjs} +25 -10
- package/lib/modules/minifyJs.mjs +121 -0
- package/lib/modules/{minifyJson.js → minifyJson.cjs} +4 -0
- package/lib/modules/minifyJson.mjs +21 -0
- package/lib/modules/minifySvg.cjs +37 -0
- package/lib/modules/minifySvg.mjs +30 -0
- package/lib/modules/{minifyUrls.js → minifyUrls.cjs} +7 -8
- package/lib/modules/minifyUrls.mjs +229 -0
- package/lib/modules/{normalizeAttributeValues.js → normalizeAttributeValues.cjs} +0 -5
- package/lib/modules/normalizeAttributeValues.mjs +140 -0
- package/lib/modules/removeAttributeQuotes.mjs +12 -0
- package/lib/modules/{removeComments.js → removeComments.cjs} +1 -1
- package/lib/modules/removeComments.mjs +92 -0
- package/lib/modules/{removeEmptyAttributes.js → removeEmptyAttributes.cjs} +1 -1
- package/lib/modules/removeEmptyAttributes.mjs +121 -0
- package/lib/modules/{removeOptionalTags.js → removeOptionalTags.cjs} +1 -1
- package/lib/modules/removeOptionalTags.mjs +225 -0
- package/lib/modules/{removeRedundantAttributes.js → removeRedundantAttributes.cjs} +1 -2
- package/lib/modules/removeRedundantAttributes.mjs +141 -0
- package/lib/modules/{removeUnusedCss.js → removeUnusedCss.cjs} +12 -13
- package/lib/modules/removeUnusedCss.mjs +122 -0
- package/lib/modules/sortAttributes.mjs +121 -0
- package/lib/modules/{sortAttributesWithLists.js → sortAttributesWithLists.cjs} +1 -1
- package/lib/modules/sortAttributesWithLists.mjs +135 -0
- package/lib/presets/{ampSafe.js → ampSafe.cjs} +4 -9
- package/lib/presets/ampSafe.mjs +11 -0
- package/lib/presets/{max.js → max.cjs} +4 -9
- package/lib/presets/max.mjs +20 -0
- package/lib/presets/{safe.js → safe.cjs} +2 -3
- package/lib/presets/safe.mjs +65 -0
- package/package.json +40 -12
- package/test.js +48 -0
- package/index.js +0 -1
- package/lib/helpers.js +0 -52
- package/lib/htmlnano.js +0 -147
- package/lib/modules/minifySvg.js +0 -38
- /package/lib/modules/{collapseBooleanAttributes.js → collapseBooleanAttributes.cjs} +0 -0
- /package/lib/modules/{custom.js → custom.cjs} +0 -0
- /package/lib/modules/{removeAttributeQuotes.js → removeAttributeQuotes.cjs} +0 -0
- /package/lib/modules/{sortAttributes.js → sortAttributes.cjs} +0 -0
package/.eslintignore
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
lib/modules/example.
|
|
2
|
-
test.
|
|
1
|
+
lib/modules/example.mjs
|
|
2
|
+
test.mjs
|
|
3
|
+
**/*.cjs
|
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,39 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [2.1.0] - 2023-10-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Convert htmlnano to ES Modules [#260]
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Collapse white spaces according to specs [#257]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.0.4] - 2023-04-15
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Should not minify `<script>` and `<style>` with SRI [#220]
|
|
18
|
+
- Should not merge `<style>` or `<script>` with SRI [#220]
|
|
19
|
+
- Should not minify json with SRI [#220]
|
|
20
|
+
|
|
21
|
+
|
|
5
22
|
## [2.0.3] - 2022-11-13
|
|
6
|
-
|
|
7
|
-
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- Minify function for `HtmlMinimizerWebpackPlugin`
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- `collapseWhitespace`: handle textNode when comment is preserved [#184]
|
|
29
|
+
- `minifyUrls`: srcset & javascript: url [#185]
|
|
30
|
+
- Correct missing value default usage
|
|
31
|
+
- `collapseBooleanAttributes`: empty string attributes
|
|
32
|
+
- Guard type of attributes' value [#195]
|
|
33
|
+
- Do not choke on svg error [#197]
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Minify based on invalid value default
|
|
37
|
+
- Avoid hardcoding preset keys
|
|
8
38
|
|
|
9
39
|
|
|
10
40
|
## [2.0.2] - 2022-04-06
|
|
@@ -252,7 +282,9 @@ Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https:
|
|
|
252
282
|
- Remove attributes that contains only white spaces.
|
|
253
283
|
|
|
254
284
|
|
|
255
|
-
[2.0
|
|
285
|
+
[2.1.0]: https://github.com/posthtml/htmlnano/compare/2.0.4...2.1.0
|
|
286
|
+
[2.0.4]: https://github.com/posthtml/htmlnano/compare/2.0.3...2.0.4
|
|
287
|
+
[2.0.3]: https://github.com/posthtml/htmlnano/compare/2.0.2...2.0.3
|
|
256
288
|
[2.0.2]: https://github.com/posthtml/htmlnano/compare/2.0.1...2.0.2
|
|
257
289
|
[2.0.1]: https://github.com/posthtml/htmlnano/compare/2.0.0...2.0.1
|
|
258
290
|
[2.0.0]: https://github.com/posthtml/htmlnano/compare/1.1.1...2.0.0
|
|
@@ -281,6 +313,14 @@ Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https:
|
|
|
281
313
|
[0.1.2]: https://github.com/posthtml/htmlnano/compare/0.1.1...0.1.2
|
|
282
314
|
[0.1.1]: https://github.com/posthtml/htmlnano/compare/0.1.0...0.1.1
|
|
283
315
|
|
|
316
|
+
|
|
317
|
+
[#260]: https://github.com/posthtml/htmlnano/issues/260
|
|
318
|
+
[#257]: https://github.com/posthtml/htmlnano/issues/257
|
|
319
|
+
[#220]: https://github.com/posthtml/htmlnano/issues/220
|
|
320
|
+
[#197]: https://github.com/posthtml/htmlnano/issues/197
|
|
321
|
+
[#195]: https://github.com/posthtml/htmlnano/issues/195
|
|
322
|
+
[#185]: https://github.com/posthtml/htmlnano/issues/185
|
|
323
|
+
[#184]: https://github.com/posthtml/htmlnano/issues/184
|
|
284
324
|
[#182]: https://github.com/posthtml/htmlnano/issues/182
|
|
285
325
|
[#180]: https://github.com/posthtml/htmlnano/issues/180
|
|
286
326
|
[#170]: https://github.com/posthtml/htmlnano/issues/170
|
package/docs/docs/040-presets.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
A preset is just an object with modules config.
|
|
4
4
|
|
|
5
5
|
Currently the following presets are available:
|
|
6
|
-
- [safe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.
|
|
7
|
-
- [ampSafe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/ampSafe.
|
|
8
|
-
- [max](https://github.com/posthtml/htmlnano/blob/master/lib/presets/max.
|
|
6
|
+
- [safe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) — a default preset for minifying a regular HTML in a safe way (without breaking anything)
|
|
7
|
+
- [ampSafe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/ampSafe.mjs) - same as `safe` preset but for [AMP pages](https://www.ampproject.org/)
|
|
8
|
+
- [max](https://github.com/posthtml/htmlnano/blob/master/lib/presets/max.mjs) - maximal minification (might break some pages)
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
You can use them the following way:
|
|
@@ -26,7 +26,7 @@ htmlnano
|
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
If you skip `preset` argument [`safe`](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.
|
|
29
|
+
If you skip `preset` argument [`safe`](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) preset would be used by default.
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
If you'd like to define your very own config without any presets pass an empty object as a preset:
|
package/docs/docs/050-modules.md
CHANGED
|
@@ -26,7 +26,7 @@ Minified:
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### removeEmptyAttributes
|
|
29
|
-
Removes empty [safe-to-remove](https://github.com/posthtml/htmlnano/blob/master/lib/modules/removeEmptyAttributes.
|
|
29
|
+
Removes empty [safe-to-remove](https://github.com/posthtml/htmlnano/blob/master/lib/modules/removeEmptyAttributes.mjs) attributes.
|
|
30
30
|
|
|
31
31
|
#### Side effects
|
|
32
32
|
This module could break your styles or JS if you use selectors with attributes:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Since the minifier is modular, it's very easy to add new modules:
|
|
4
4
|
|
|
5
|
-
1. Create a ES6-file inside `lib/modules/` with a function that does some minification. For example you can check [`lib/modules/example.
|
|
5
|
+
1. Create a ES6-file inside `lib/modules/` with a function that does some minification. For example you can check [`lib/modules/example.mjs`](https://github.com/posthtml/htmlnano/blob/master/lib/modules/example.mjs).
|
|
6
6
|
|
|
7
7
|
2. Add the module's name into one of those [presets](https://github.com/posthtml/htmlnano/tree/master/lib/presets). You can choose either `ampSafe`, `max`, or `safe`.
|
|
8
8
|
|
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
organizationName: 'posthtml',
|
|
14
14
|
projectName: 'htmlnano',
|
|
15
15
|
trailingSlash: false,
|
|
16
|
+
plugins: ['docusaurus-plugin-goatcounter'],
|
|
16
17
|
themeConfig: {
|
|
17
18
|
navbar: {
|
|
18
19
|
title: 'htmlnano',
|
|
@@ -33,6 +34,9 @@ module.exports = {
|
|
|
33
34
|
theme: lightCodeTheme,
|
|
34
35
|
darkTheme: darkCodeTheme,
|
|
35
36
|
},
|
|
37
|
+
goatcounter: {
|
|
38
|
+
code: 'htmlnano',
|
|
39
|
+
},
|
|
36
40
|
},
|
|
37
41
|
presets: [
|
|
38
42
|
[
|
|
@@ -50,6 +54,7 @@ module.exports = {
|
|
|
50
54
|
|
|
51
55
|
|
|
52
56
|
const algoliaConfig = {
|
|
57
|
+
appId: process.env.ALGOLIA_APP_ID,
|
|
53
58
|
apiKey: process.env.ALGOLIA_API_KEY,
|
|
54
59
|
indexName: 'htmlnano',
|
|
55
60
|
contextualSearch: true,
|