From c64c0783659c98edfe4ec90a4d233058a7f31918 Mon Sep 17 00:00:00 2001 From: Spirit Date: Mon, 26 Aug 2024 16:29:29 +0300 Subject: [PATCH] create `html-minify.sh` --- html-minify.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 html-minify.sh diff --git a/html-minify.sh b/html-minify.sh new file mode 100755 index 0000000..bdc5f30 --- /dev/null +++ b/html-minify.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Known issues: +# - if html line have two paths only one file considered +# - fails if js file has backticks + +command -v html-minifier >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } +command -v uglifyjs >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } +command -v cleancss >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } +command -v svgo >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } + +html_file=index.html + +if [[ -f "$html_file" ]]; then + awk ' + { + if (match($0, /