add html-minify

This commit is contained in:
Stefan Feješ
2017-12-20 14:25:37 +01:00
parent 25e1879596
commit b15c1d0401
4 changed files with 489 additions and 1112 deletions

File diff suppressed because one or more lines are too long

114
package-lock.json generated
View File

@ -322,6 +322,15 @@
"resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz",
"integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=" "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo="
}, },
"camel-case": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz",
"integrity": "sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M=",
"requires": {
"no-case": "2.3.2",
"upper-case": "1.1.3"
}
},
"camelcase": { "camelcase": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
@ -389,6 +398,14 @@
"resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz",
"integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==" "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A=="
}, },
"clean-css": {
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.1.9.tgz",
"integrity": "sha1-Nc7ornaHpJuYA09w3gDE7dOCYwE=",
"requires": {
"source-map": "0.5.7"
}
},
"cli-boxes": { "cli-boxes": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz",
@ -1398,6 +1415,33 @@
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
"integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo="
}, },
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
},
"html-minifier": {
"version": "3.5.7",
"resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.7.tgz",
"integrity": "sha512-GISXn6oKDo7+gVpKOgZJTbHMCUI2TSGfpg/8jgencWhWJsvEmsvp3M8emX7QocsXsYznWloLib3OeSfeyb/ewg==",
"requires": {
"camel-case": "3.0.0",
"clean-css": "4.1.9",
"commander": "2.12.2",
"he": "1.1.1",
"ncname": "1.0.0",
"param-case": "2.1.1",
"relateurl": "0.2.7",
"uglify-js": "3.2.2"
},
"dependencies": {
"commander": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz",
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA=="
}
}
},
"http-auth": { "http-auth": {
"version": "3.1.3", "version": "3.1.3",
"resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz", "resolved": "https://registry.npmjs.org/http-auth/-/http-auth-3.1.3.tgz",
@ -1971,6 +2015,11 @@
"resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz",
"integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=" "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU="
}, },
"lower-case": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz",
"integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw="
},
"lowercase-keys": { "lowercase-keys": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz",
@ -2123,11 +2172,27 @@
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc="
}, },
"ncname": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/ncname/-/ncname-1.0.0.tgz",
"integrity": "sha1-W1etGLHKCShk72Kwse2BlPODtxw=",
"requires": {
"xml-char-classes": "1.0.0"
}
},
"negotiator": { "negotiator": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
}, },
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
"integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==",
"requires": {
"lower-case": "1.1.4"
}
},
"nodemon": { "nodemon": {
"version": "1.12.1", "version": "1.12.1",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.12.1.tgz", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.12.1.tgz",
@ -2299,6 +2364,14 @@
"semver": "5.4.1" "semver": "5.4.1"
} }
}, },
"param-case": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz",
"integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=",
"requires": {
"no-case": "2.3.2"
}
},
"parse-glob": { "parse-glob": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz",
@ -2601,6 +2674,11 @@
"rc": "1.2.2" "rc": "1.2.2"
} }
}, },
"relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
},
"remove-trailing-separator": { "remove-trailing-separator": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
@ -2820,6 +2898,11 @@
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz",
"integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=" "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU="
}, },
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
},
"spawn-command": { "spawn-command": {
"version": "0.0.2-1", "version": "0.0.2-1",
"resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz",
@ -3037,6 +3120,27 @@
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.3.tgz",
"integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI=" "integrity": "sha1-ftUNXg+an7ClczeSWfKndFjVAZI="
}, },
"uglify-js": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.2.2.tgz",
"integrity": "sha512-++1NO/zZIEdWf6cDIGceSJQPX31SqIpbVAHwFG5+240MtZqPG/NIPoinj8zlXQtAfMBqEt1Jyv2FiLP3n9gVhQ==",
"requires": {
"commander": "2.12.2",
"source-map": "0.6.1"
},
"dependencies": {
"commander": {
"version": "2.12.2",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz",
"integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA=="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
}
}
},
"undefsafe": { "undefsafe": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-0.0.3.tgz", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-0.0.3.tgz",
@ -3124,6 +3228,11 @@
} }
} }
}, },
"upper-case": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz",
"integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg="
},
"url-parse-lax": { "url-parse-lax": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz",
@ -3256,6 +3365,11 @@
"resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz",
"integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=" "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ="
}, },
"xml-char-classes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/xml-char-classes/-/xml-char-classes-1.0.0.tgz",
"integrity": "sha1-ZGV4SKIP/F31g6Qq2KJ3tFErvE0="
},
"xtend": { "xtend": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",

View File

@ -2,6 +2,7 @@
"dependencies": { "dependencies": {
"concurrently": "^3.5.1", "concurrently": "^3.5.1",
"fs-extra": "^4.0.2", "fs-extra": "^4.0.2",
"html-minifier": "^3.5.7",
"live-server": "^1.2.0", "live-server": "^1.2.0",
"markdown-it": "^8.4.0", "markdown-it": "^8.4.0",
"nodemon": "^1.12.1", "nodemon": "^1.12.1",

View File

@ -3,8 +3,12 @@
Run using `npm run webber`. Run using `npm run webber`.
*/ */
// Load modules // Load modules
const fs = require('fs-extra'), path = require('path'), chalk = require('chalk'), const fs = require('fs-extra');
md = require('markdown-it')(); const path = require('path');
const chalk = require('chalk');
const md = require('markdown-it')();
const minify = require('html-minifier').minify;
// Set variables for paths // Set variables for paths
const snippetsPath = './snippets', staticPartsPath = './static-parts', docsPath = './docs'; const snippetsPath = './snippets', staticPartsPath = './static-parts', docsPath = './docs';
// Set variables for script // Set variables for script
@ -70,6 +74,25 @@ try {
// Add the ending static part // Add the ending static part
output += `\n${endPart+'\n'}`; output += `\n${endPart+'\n'}`;
// Write to the index.html file // Write to the index.html file
output = minify(output, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
decodeEntities: true,
minifyCSS: true,
minifyJS: true,
html5: false,
processConditionalComments: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeOptionalTags: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
trimCustomFragments: true,
useShortDoctype: true,
});
fs.writeFileSync(path.join(docsPath,'index.html'), output); fs.writeFileSync(path.join(docsPath,'index.html'), output);
} }
catch (err){ // Handle errors (hopefully not!) catch (err){ // Handle errors (hopefully not!)