Fix posthook to work no matter what the structure of assets

This commit is contained in:
James Mills 2023-03-30 20:23:00 +10:00
parent 9be5115b6b
commit 303eebf94b
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -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"
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"