htmlnano 0.1.10 → 0.2.3
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 +1 -0
- package/CHANGELOG.md +56 -0
- package/README.md +239 -112
- package/lib/helpers.js +47 -0
- package/lib/htmlnano.js +40 -40
- package/lib/modules/collapseAttributeWhitespace.js +30 -0
- package/lib/modules/collapseBooleanAttributes.js +15 -7
- package/lib/modules/collapseWhitespace.js +14 -7
- package/lib/modules/deduplicateAttributeValues.js +48 -0
- package/lib/modules/mergeScripts.js +19 -19
- package/lib/modules/mergeStyles.js +7 -0
- package/lib/modules/minifyCss.js +13 -3
- package/lib/modules/removeEmptyAttributes.js +2 -2
- package/lib/modules/removeUnusedCss.js +75 -0
- package/lib/presets/ampSafe.js +27 -0
- package/lib/presets/hard.js +26 -0
- package/lib/presets/max.js +31 -0
- package/lib/presets/safe.js +31 -0
- package/package.json +20 -11
- package/test.js +18 -15
- package/test.html +0 -14
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htmlnano",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Modular HTML minifier, built on top of the PostHTML",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Kirill Maltsev <maltsevkirill@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"compile": "rimraf lib/*.js && rimraf lib/modules/*.js && babel -d lib/ lib/",
|
|
10
|
-
"lint": "eslint *.js lib/*.es6 lib/modules/*.es6 test/",
|
|
10
|
+
"lint": "eslint *.js lib/*.es6 lib/modules/*.es6 lib/presets/*.es6 test/",
|
|
11
11
|
"pretest": "npm run lint && npm run compile",
|
|
12
12
|
"test": ":",
|
|
13
13
|
"posttest": "mocha --require babel-core/register --recursive --check-leaks --globals addresses",
|
|
14
|
-
"prepare": "npm run compile"
|
|
14
|
+
"prepare": "npm run compile",
|
|
15
|
+
"release:patch": "release-it patch -n"
|
|
16
|
+
},
|
|
17
|
+
"release-it": {
|
|
18
|
+
"scripts": {
|
|
19
|
+
"beforeStart": "npm test"
|
|
20
|
+
}
|
|
15
21
|
},
|
|
16
22
|
"keywords": [
|
|
17
23
|
"posthtml",
|
|
@@ -22,26 +28,29 @@
|
|
|
22
28
|
],
|
|
23
29
|
"babel": {
|
|
24
30
|
"presets": [
|
|
25
|
-
"
|
|
31
|
+
"env"
|
|
26
32
|
]
|
|
27
33
|
},
|
|
28
34
|
"dependencies": {
|
|
29
|
-
"cssnano": "^
|
|
35
|
+
"cssnano": "^4.1.9",
|
|
36
|
+
"normalize-html-whitespace": "^0.2.0",
|
|
30
37
|
"object-assign": "^4.0.1",
|
|
31
38
|
"posthtml": "^0.11.3",
|
|
32
39
|
"posthtml-render": "^1.1.4",
|
|
33
40
|
"svgo": "^1.0.5",
|
|
34
|
-
"terser": "^3.
|
|
41
|
+
"terser": "^3.16.1",
|
|
42
|
+
"uncss": "^0.16.2"
|
|
35
43
|
},
|
|
36
44
|
"devDependencies": {
|
|
37
45
|
"babel-cli": "^6.26.0",
|
|
38
46
|
"babel-core": "^6.26.3",
|
|
39
|
-
"babel-eslint": "^
|
|
40
|
-
"babel-preset-
|
|
41
|
-
"eslint": "^5.
|
|
42
|
-
"expect": "^
|
|
47
|
+
"babel-eslint": "^10.0.0",
|
|
48
|
+
"babel-preset-env": "^1.7.0",
|
|
49
|
+
"eslint": "^5.13.0",
|
|
50
|
+
"expect": "^24.0.0",
|
|
43
51
|
"mocha": "^5.2.0",
|
|
44
|
-
"
|
|
52
|
+
"release-it": "^10.0.0",
|
|
53
|
+
"rimraf": "^2.6.3"
|
|
45
54
|
},
|
|
46
55
|
"repository": {
|
|
47
56
|
"type": "git",
|
package/test.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// // removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
|
|
5
|
-
// // collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
|
6
|
-
// };
|
|
1
|
+
const htmlnano = require('./index');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const safePreset = require('./lib/presets/safe').default;
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// `;
|
|
5
|
+
const options = {
|
|
6
|
+
minifySvg: safePreset.minifySvg,
|
|
7
|
+
};
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
console.log(options);
|
|
10
|
+
|
|
11
|
+
const svg = fs.readFileSync('./orig.html', 'utf8');
|
|
12
|
+
|
|
13
|
+
htmlnano
|
|
14
|
+
.process(svg, options, {})
|
|
15
|
+
.then(function (result) {
|
|
16
|
+
console.log(result.html);
|
|
17
|
+
})
|
|
18
|
+
.catch(function (err) {
|
|
19
|
+
console.error(err);
|
|
20
|
+
});
|