@jsenv/plugin-minification 1.2.3 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-minification",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "html-minifier": "4.0.0",
28
28
  "lightningcss": "1.20.0",
29
- "terser": "5.17.4"
29
+ "terser": "5.17.5"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@jsenv/core": "*"
@@ -5,11 +5,24 @@ export const minifyHtml = ({ htmlUrlInfo, options } = {}) => {
5
5
  const require = createRequire(import.meta.url);
6
6
  const { minify } = require("html-minifier");
7
7
 
8
- const { collapseWhitespace = true, removeComments = true } = options;
8
+ const {
9
+ // usually HTML will contain a few markup, it's better to keep white spaces
10
+ // and line breaks to favor readability. A few white spaces means very few
11
+ // octets that won't impact performances. Removing whitespaces however will certainly
12
+ // decrease HTML readability
13
+ collapseWhitespace = false,
14
+ // saving a fewline breaks won't hurt performances
15
+ // but will help a lot readability
16
+ preserveLineBreaks = true,
17
+ removeComments = true,
18
+ conservativeCollapse = false,
19
+ } = options;
9
20
 
10
21
  const htmlMinified = minify(htmlUrlInfo.content, {
11
22
  collapseWhitespace,
23
+ conservativeCollapse,
12
24
  removeComments,
25
+ preserveLineBreaks,
13
26
  });
14
27
  return htmlMinified;
15
28
  };