fix: handle target directory for image conversion in build script

This commit is contained in:
Kevin Peng
2025-04-20 09:24:02 +08:00
parent b840200faf
commit 1985d78cb2

View File

@@ -21,6 +21,9 @@ echo "$image_files"
echo "Converting images to WebP format..."
for file in $image_files; do
target_dir="dist/images/$(dirname "$file" | sed "s|^src/images/||")"
if [[ "$target_dir" == "dist/images/" ]]; then
target_dir="dist/images"
fi
mkdir -p "$target_dir"
echo "Processing image: $file -> $target_dir/$(basename "${file%.*}.webp")"
cwebp "$file" -o "$target_dir/$(basename "${file%.*}.webp")"