#!/bin/bash # Known issues: # - it graps only one file path from each HTML line and removes other paths in the same line # - 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 clean-css-cli 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 clean-css-cli 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 clean-css-cli 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 clean-css-cli svgo" >&2; exit 1; } if [[ $# -eq 0 ]]; then html_file=index.html else html_file="$1" dir=$PWD cd $(dirname $html_file) html_file=$(basename $html_file) fi if [[ -f "$html_file" ]]; then original_sizes=$(stat -c %s $html_file) awk ' { if (match($0, /