From 303eebf94bf09a898094c07b2438d19dd19c144d Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Thu, 30 Mar 2023 20:23:00 +1000 Subject: [PATCH] Fix posthook to work no matter what the structure of assets --- .zs/posthook | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.zs/posthook b/.zs/posthook index 921f291..b61aa3f 100755 --- a/.zs/posthook +++ b/.zs/posthook @@ -2,13 +2,16 @@ set -e -CSS="bahunya site" -JS="live" +minify_assets() { + p="$1" + t="$2" -for css in $CSS; do - minify -o "$ZS_OUTDIR/css/$css.min.css" "$ZS_OUTDIR/css/$css.css" -done + find "$p" -type f -name "*.$t" | while read -r file; do + name="${file#"$p"}" + name="${name#"/"}" + minify -o "${p}/${name}" "$file" + done +} -for js in $JS; do - minify -o "$ZS_OUTDIR/js/$js.min.js" "$ZS_OUTDIR/js/$js.js" -done +minify_assets "$ZS_OUTDIR" "css" +minify_assets "$ZS_OUTDIR" "js"