added more compression tools

This commit is contained in:
Samuel Philipp 2021-06-14 23:22:40 +02:00
parent c08ebac8aa
commit 121e4d8e24
Signed by untrusted user: samuel-p
GPG key ID: 2AD495D17760CB4E
2 changed files with 38 additions and 2 deletions

32
.compress-all.js Normal file
View file

@ -0,0 +1,32 @@
const glob = require("glob");
const minify = require('@node-minify/core');
const htmlMinifier = require('@node-minify/html-minifier');
const crass = require('@node-minify/crass');
console.log('compress all html and css files');
glob("dist/**/*.html", function (er, files) {
files.forEach(file => {
console.log(file);
minify({
compressor: htmlMinifier,
input: file,
output: file,
options: {
collapseWhitespace: true,
conservativeCollapse: true
},
});
})
});
glob("dist/**/*.css", function (er, files) {
files.forEach(file => {
console.log(file);
minify({
compressor: crass,
input: file,
output: file
});
})
});

View file

@ -4,12 +4,11 @@
"description": "website for sp-codes.de", "description": "website for sp-codes.de",
"scripts": { "scripts": {
"compile-sass": "node-sass --output-style compressed --importer=node_modules/node-sass-tilde-importer src/scss/main.scss -o dist/css/", "compile-sass": "node-sass --output-style compressed --importer=node_modules/node-sass-tilde-importer src/scss/main.scss -o dist/css/",
"p-minify-css": "purifycss dist/css/main.css dist/**/*.html dist/**/**/*.html dist/**/**/**/*.html -i -m -o dist/css/main.css",
"minify-css": "uncss -n -H dist/ -o dist/css/main.css dist/**/*.html dist/**/**/*.html dist/**/**/**/*.html", "minify-css": "uncss -n -H dist/ -o dist/css/main.css dist/**/*.html dist/**/**/*.html dist/**/**/**/*.html",
"watch:eleventy": "eleventy --serve", "watch:eleventy": "eleventy --serve",
"watch:sass": "npm-run-all compile-sass minify-css -- --watch", "watch:sass": "npm-run-all compile-sass minify-css -- --watch",
"start": "npm-run-all compile-sass minify-css --parallel watch:*", "start": "npm-run-all compile-sass minify-css --parallel watch:*",
"build": "npm run compile-sass && eleventy && npm run move-index && npm run minify-css", "build": "npm run compile-sass && eleventy && npm run move-index && npm run minify-css && node .compress-all.js",
"move-index": "cpx dist/de/index.html dist/" "move-index": "cpx dist/de/index.html dist/"
}, },
"author": "samuel-p", "author": "samuel-p",
@ -23,7 +22,12 @@
"devDependencies": { "devDependencies": {
"@11ty/eleventy": "^1.0.0-canary.33", "@11ty/eleventy": "^1.0.0-canary.33",
"@11ty/eleventy-navigation": "^0.2.0", "@11ty/eleventy-navigation": "^0.2.0",
"@node-minify/core": "^6.2.0",
"@node-minify/crass": "^6.2.0",
"@node-minify/html-minifier": "^6.2.0",
"cpx": "^1.5.0", "cpx": "^1.5.0",
"glob": "^7.1.7",
"minify": "^7.0.2",
"node-sass": "^6.0.0", "node-sass": "^6.0.0",
"node-sass-tilde-importer": "^1.0.2", "node-sass-tilde-importer": "^1.0.2",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",