htmlnano 1.1.0 → 2.0.1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +8 -13
  3. package/docs/docs/050-modules.md +54 -2
  4. package/docs/package-lock.json +14644 -824
  5. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/010-introduction.md +0 -0
  6. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/020-usage.md +0 -0
  7. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/030-config.md +0 -0
  8. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/040-presets.md +0 -0
  9. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/050-modules.md +0 -0
  10. package/docs/versioned_docs/{version-1.1.0 → version-1.1.1}/060-contribute.md +0 -0
  11. package/docs/versioned_docs/version-2.0.0/010-introduction.md +22 -0
  12. package/docs/versioned_docs/version-2.0.0/020-usage.md +77 -0
  13. package/docs/versioned_docs/version-2.0.0/030-config.md +21 -0
  14. package/docs/versioned_docs/version-2.0.0/040-presets.md +75 -0
  15. package/docs/versioned_docs/version-2.0.0/050-modules.md +838 -0
  16. package/docs/versioned_docs/version-2.0.0/060-contribute.md +16 -0
  17. package/docs/versioned_sidebars/{version-1.1.0-sidebars.json → version-1.1.1-sidebars.json} +1 -1
  18. package/docs/versioned_sidebars/version-2.0.0-sidebars.json +8 -0
  19. package/docs/versions.json +2 -1
  20. package/lib/helpers.js +15 -2
  21. package/lib/htmlnano.js +78 -4
  22. package/lib/modules/collapseAttributeWhitespace.js +21 -21
  23. package/lib/modules/collapseBooleanAttributes.js +13 -19
  24. package/lib/modules/deduplicateAttributeValues.js +10 -16
  25. package/lib/modules/minifyCss.js +8 -8
  26. package/lib/modules/minifyJs.js +6 -9
  27. package/lib/modules/minifyJson.js +12 -23
  28. package/lib/modules/minifySvg.js +5 -2
  29. package/lib/modules/minifyUrls.js +29 -22
  30. package/lib/modules/normalizeAttributeValues.js +9 -15
  31. package/lib/modules/removeComments.js +17 -9
  32. package/lib/modules/removeEmptyAttributes.js +13 -16
  33. package/lib/modules/removeRedundantAttributes.js +19 -23
  34. package/lib/modules/removeUnusedCss.js +10 -10
  35. package/lib/presets/max.js +2 -0
  36. package/lib/presets/safe.js +2 -2
  37. package/package.json +49 -13
  38. package/uncss-fork.patch +0 -13
package/CHANGELOG.md CHANGED
@@ -2,8 +2,28 @@
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.0.1] - 2022-04-04
6
+
7
+ ### Changed
8
+ - Speed improvements [#127]
9
+ - Fix `<img sizes>` [#180]
10
+
11
+
12
+ ## [2.0.0] - 2022-01-12
13
+ *The major version has to be released because of vulnerability in PostCSS (see [#165])*
14
+
15
+ ### Changed
16
+ - Support optional dependencies [#168] (`minifyUrl`, ` minifyJs`, `removeUnusedCss`, `minifyCss`). *This might be a breaking change for you*. Check the docs: https://github.com/posthtml/htmlnano/pull/168/files
17
+ - Disable `mergeScripts` & `mergeStyles` in the safe preset [#170].
18
+
19
+
20
+ ## [1.1.1] - 2021-09-19
21
+ This version fixes fatal errors introduced in [1.1.0].
22
+
5
23
 
6
24
  ## [1.1.0] - 2021-09-19
25
+ *This version contains fatal errors. Please use [1.1.1] instead.*
26
+
7
27
  ### Added
8
28
  - Collapse missing value default attribute in `removeRedundantAttributes` [#158].
9
29
  - New `normalizeAttributeValues` module to normalize casing of attribute values [#163].
@@ -219,6 +239,9 @@ Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https:
219
239
  - Remove attributes that contains only white spaces.
220
240
 
221
241
 
242
+ [2.0.1]: https://github.com/posthtml/htmlnano/compare/2.0.0...2.0.1
243
+ [2.0.0]: https://github.com/posthtml/htmlnano/compare/1.1.1...2.0.0
244
+ [1.1.1]: https://github.com/posthtml/htmlnano/compare/1.1.0...1.1.1
222
245
  [1.1.0]: https://github.com/posthtml/htmlnano/compare/1.0.1...1.1.0
223
246
  [1.0.1]: https://github.com/posthtml/htmlnano/compare/1.0.0...1.0.1
224
247
  [1.0.0]: https://github.com/posthtml/htmlnano/compare/0.2.9...1.0.0
@@ -243,6 +266,10 @@ Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https:
243
266
  [0.1.2]: https://github.com/posthtml/htmlnano/compare/0.1.1...0.1.2
244
267
  [0.1.1]: https://github.com/posthtml/htmlnano/compare/0.1.0...0.1.1
245
268
 
269
+ [#180]: https://github.com/posthtml/htmlnano/issues/180
270
+ [#170]: https://github.com/posthtml/htmlnano/issues/170
271
+ [#168]: https://github.com/posthtml/htmlnano/issues/168
272
+ [#165]: https://github.com/posthtml/htmlnano/issues/165
246
273
  [#163]: https://github.com/posthtml/htmlnano/issues/163
247
274
  [#161]: https://github.com/posthtml/htmlnano/issues/161
248
275
  [#159]: https://github.com/posthtml/htmlnano/issues/159
@@ -254,6 +281,7 @@ Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https:
254
281
  [#145]: https://github.com/posthtml/htmlnano/issues/145
255
282
  [#135]: https://github.com/posthtml/htmlnano/issues/135
256
283
  [#129]: https://github.com/posthtml/htmlnano/issues/129
284
+ [#127]: https://github.com/posthtml/htmlnano/issues/127
257
285
  [#125]: https://github.com/posthtml/htmlnano/issues/125
258
286
  [#122]: https://github.com/posthtml/htmlnano/issues/122
259
287
  [#120]: https://github.com/posthtml/htmlnano/issues/120
package/README.md CHANGED
@@ -4,22 +4,17 @@
4
4
 
5
5
  Modular HTML minifier, built on top of the [PostHTML](https://github.com/posthtml/posthtml). Inspired by [cssnano](http://cssnano.co/).
6
6
 
7
- To switch to the optional fork of uncss, apply `uncss-fork.patch`.
8
-
9
- Reasons you may want to do this are: uncss uses outdated dependencies with security issues
10
-
11
- Reasons you may want to avoid this are: long term support, stability
12
-
13
7
  ## [Benchmark](https://github.com/maltsev/html-minifiers-benchmark/blob/master/README.md)
14
- [html-minifier-terser@5.1.1]: https://www.npmjs.com/package/html-minifier-terser
15
- [htmlnano@1.0.0]: https://www.npmjs.com/package/htmlnano
8
+ [html-minifier-terser@6.0.2]: https://www.npmjs.com/package/html-minifier-terser
9
+ [htmlnano@1.1.1]: https://www.npmjs.com/package/htmlnano
16
10
 
17
- | Website | Source (KB) | [html-minifier-terser@5.1.1] | [htmlnano@1.0.0] |
11
+ | Website | Source (KB) | [html-minifier-terser@6.0.2] | [htmlnano@1.1.1] |
18
12
  |---------|------------:|----------------:|-----------:|
19
- | [stackoverflow.blog](https://stackoverflow.blog/) | 95 | 87 | 82 |
20
- | [github.com](https://github.com/) | 210 | 183 | 171 |
21
- | [en.wikipedia.org](https://en.wikipedia.org/wiki/Main_Page) | 78 | 72 | 72 |
22
- | [npmjs.com](https://www.npmjs.com/features) | 41 | 38 | 36 |
13
+ | [stackoverflow.blog](https://stackoverflow.blog/) | 90 | 82 | 76 |
14
+ | [github.com](https://github.com/) | 232 | 203 | 173 |
15
+ | [en.wikipedia.org](https://en.wikipedia.org/wiki/Main_Page) | 81 | 76 | 75 |
16
+ | [npmjs.com](https://www.npmjs.com/features) | 43 | 40 | 38 |
17
+ | [tc39.es](https://tc39.es/ecma262/) | 6001 | 5465 | 5459 |
23
18
  | **Avg. minify rate** | 0% | **9%** | **13%** |
24
19
 
25
20
 
@@ -203,6 +203,19 @@ or [PurgeCSS](https://github.com/FullHuman/purgecss).
203
203
 
204
204
  #### With uncss
205
205
 
206
+ You have to install `uncss` in order to use this feature:
207
+
208
+ ```bash
209
+ npm install --save-dev uncss
210
+ # if you prefer yarn
211
+ # yarn add --dev uncss
212
+ # if you prefer pnpm
213
+ # pnpm install --save-dev uncss
214
+ ```
215
+
216
+ You can also use a mainted fork [@novaatwarren/uncss](https://www.npmjs.com/package/@novaatwarren/uncss) instead.
217
+
218
+
206
219
  ##### Options
207
220
  See [the documentation of uncss](https://github.com/uncss/uncss) for all supported options.
208
221
 
@@ -225,6 +238,16 @@ The following uncss options are ignored if passed to the module:
225
238
 
226
239
  Use PurgeCSS instead of uncss by adding `tool: 'purgeCSS'` to the options.
227
240
 
241
+ You have to install `purgecss` in order to use this feature:
242
+
243
+ ```bash
244
+ npm install --save-dev purgecss
245
+ # if you prefer yarn
246
+ # yarn add --dev purgecss
247
+ # if you prefer pnpm
248
+ # pnpm install --save-dev purgecss
249
+ ```
250
+
228
251
  ##### Options
229
252
 
230
253
  See [the documentation of PurgeCSS](https://www.purgecss.com) for all supported options.
@@ -275,8 +298,18 @@ Optimized:
275
298
  ### minifyCss
276
299
  Minifies CSS with [cssnano](http://cssnano.co/) inside `<style>` tags and `style` attributes.
277
300
 
301
+ You have to install `cssnano` and `postcss` in order to use this feature:
302
+
303
+ ```bash
304
+ npm install --save-dev cssnano postcss
305
+ # if you prefer yarn
306
+ # yarn add --dev cssnano postcss
307
+ # if you prefer pnpm
308
+ # pnpm install --save-dev cssnano postcss
309
+ ```
310
+
278
311
  #### Options
279
- See [the documentation of cssnano](http://cssnano.co/optimisations/) for all supported optimizations.
312
+ See [the documentation of cssnano](http://cssnano.co/docs/optimisations/) for all supported optimizations.
280
313
  By default CSS is minified with preset `default`, which shouldn't have any side-effects.
281
314
 
282
315
  To use another preset or disabled some optimizations pass options to `minifyCss` module:
@@ -316,6 +349,16 @@ Minified:
316
349
  ### minifyJs
317
350
  Minifies JS using [Terser](https://github.com/fabiosantoscode/terser) inside `<script>` tags.
318
351
 
352
+ You have to install `terser` in order to use this feature:
353
+
354
+ ```bash
355
+ npm install --save-dev terser
356
+ # if you prefer yarn
357
+ # yarn add --dev terser
358
+ # if you prefer pnpm
359
+ # pnpm install --save-dev terser
360
+ ```
361
+
319
362
  #### Options
320
363
  See [the documentation of Terser](https://github.com/fabiosantoscode/terser#api-reference) for all supported options.
321
364
  Terser options can be passed directly to the `minifyJs` module:
@@ -664,6 +707,16 @@ Processed:
664
707
  ### minifyUrls
665
708
  Convert absolute URL to relative URL using [relateurl](https://www.npmjs.com/package/relateurl).
666
709
 
710
+ You have to install `relateurl`, `terser` and `srcset` in order to use this feature:
711
+
712
+ ```bash
713
+ npm install --save-dev relateurl terser srcset
714
+ # if you prefer yarn
715
+ # yarn add --dev relateurl terser srcset
716
+ # if you prefer pnpm
717
+ # pnpm install --save-dev relateurl terser srcset
718
+ ```
719
+
667
720
  #### Options
668
721
 
669
722
  The base URL to resolve against. Support `String` & `URL`.
@@ -783,4 +836,3 @@ Minified:
783
836
  ```html
784
837
  <form method="get"></form>
785
838
  ```
786
-