Setup auto-image compression on build

This commit is contained in:
BuyMyMojo 2024-12-17 13:58:23 +11:00
parent 627b43c7c4
commit 803efaa69e
2 changed files with 18 additions and 1 deletions

17
compress-images.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
if command -v jpegoptim >/dev/null 2>&1 ; then
echo "jpegoptim found"
find ./public \( -iname "*.jpg" -o -iname "*.jpeg" \) | jpegoptim -p -P --files-stdin -w $(nproc --all)
else
echo "jpegoptim was not found! install either with your package manager or get the binary from the github"
echo "https://github.com/tjko/jpegoptim/releases/latest"
fi
if command -v oxipng >/dev/null 2>&1 ; then
echo "oxipng found"
oxipng -o max -a -r ./public
else
echo "oxipng was not found! install with your package manager, cargo or get the binary from the github"
echo "https://github.com/shssoichiro/oxipng/releases/latest"
fi

View file

@ -4,7 +4,7 @@
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"build": "astro check && ./compress-images.sh && astro build",
"preview": "astro preview",
"astro": "astro"
},