htmlnano 0.2.5 → 0.2.9

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": "htmlnano",
3
- "version": "0.2.5",
3
+ "version": "0.2.9",
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>",
@@ -10,7 +10,7 @@
10
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
- "posttest": "mocha --require babel-core/register --recursive --check-leaks --globals addresses",
13
+ "posttest": "mocha --require @babel/register --recursive --check-leaks --globals addresses",
14
14
  "prepare": "npm run compile",
15
15
  "release:patch": "release-it patch -n"
16
16
  },
@@ -28,29 +28,38 @@
28
28
  ],
29
29
  "babel": {
30
30
  "presets": [
31
- "env"
31
+ [
32
+ "@babel/env",
33
+ {
34
+ "targets": {
35
+ "node": 10
36
+ }
37
+ }
38
+ ]
32
39
  ]
33
40
  },
34
41
  "dependencies": {
35
- "cssnano": "^4.1.10",
36
- "normalize-html-whitespace": "^1.0.0",
37
- "posthtml": "^0.12.0",
38
- "posthtml-render": "^1.1.5",
39
- "purgecss": "^1.4.0",
42
+ "cssnano": "^4.1.11",
43
+ "posthtml": "^0.15.1",
44
+ "purgecss": "^2.3.0",
45
+ "relateurl": "^0.2.7",
46
+ "srcset": "^3.0.0",
40
47
  "svgo": "^1.3.2",
41
- "terser": "^4.3.9",
42
- "uncss": "^0.17.2"
48
+ "terser": "^5.6.1",
49
+ "timsort": "^0.3.0",
50
+ "uncss": "^0.17.3"
43
51
  },
44
52
  "devDependencies": {
45
- "babel-cli": "^6.26.0",
46
- "babel-core": "^6.26.3",
47
- "babel-eslint": "^10.0.3",
48
- "babel-preset-env": "^1.7.0",
49
- "eslint": "^6.6.0",
50
- "expect": "^24.9.0",
51
- "mocha": "^6.2.2",
52
- "release-it": "^12.4.3",
53
- "rimraf": "^3.0.0"
53
+ "@babel/cli": "^7.13.14",
54
+ "@babel/core": "^7.13.15",
55
+ "@babel/preset-env": "^7.13.15",
56
+ "@babel/register": "^7.13.14",
57
+ "babel-eslint": "^10.1.0",
58
+ "eslint": "^7.23.0",
59
+ "expect": "^26.6.2",
60
+ "mocha": "^8.3.2",
61
+ "release-it": "^14.5.1",
62
+ "rimraf": "^3.0.2"
54
63
  },
55
64
  "repository": {
56
65
  "type": "git",
package/test.js CHANGED
@@ -1,14 +1,37 @@
1
- const htmlnano = require('./index');
2
- const fs = require('fs');
3
- const preset = require('./lib/presets/max').default;
1
+ const htmlnano = require('.');
2
+ const options = {
3
+ // minifySvg: false,
4
+ // minifyJs: false,
5
+ };
6
+ // // posthtml, posthtml-render, and posthtml-parse options
7
+ // const postHtmlOptions = {
8
+ // sync: true, // https://github.com/posthtml/posthtml#usage
9
+ // lowerCaseTags: true, // https://github.com/posthtml/posthtml-parser#options
10
+ // quoteAllAttributes: false, // https://github.com/posthtml/posthtml-render#options
11
+ // };
4
12
 
5
- const options = {};
6
-
7
- const html = fs.readFileSync('./test.html', 'utf8');
13
+ const html = `
14
+ <!doctype html>
15
+ <html lang="en">
16
+ <head>
17
+ <meta charset="utf-8">
18
+ <title></title>
19
+ <script class="fob">alert(1)</script>
20
+ <script>alert(2)</script>
21
+ </head>
22
+ <body>
23
+ <script>alert(3)</script>
24
+ <script>alert(4)</script>
25
+ </body>
26
+ </html>
27
+ `;
8
28
 
9
29
  htmlnano
10
- .process(html, options, preset)
30
+ // "preset" arg might be skipped (see "Presets" section below for more info)
31
+ // "postHtmlOptions" arg might be skipped
32
+ .process(html, options)
11
33
  .then(function (result) {
34
+ // result.html is minified
12
35
  console.log(result.html);
13
36
  })
14
37
  .catch(function (err) {
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _objectAssign = require('object-assign');
8
-
9
- var _objectAssign2 = _interopRequireDefault(_objectAssign);
10
-
11
- var _safe = require('./safe');
12
-
13
- var _safe2 = _interopRequireDefault(_safe);
14
-
15
- function _interopRequireDefault(obj) {
16
- return obj && obj.__esModule ? obj : { default: obj };
17
- }
18
-
19
- /**
20
- *
21
- */
22
- exports.default = (0, _objectAssign2.default)({}, _safe2.default, {
23
- collapseWhitespace: 'all',
24
- removeComments: 'all',
25
- removeRedundantAttributes: true
26
- });