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, /