#!/usr/bin/env zsh

echo "compressing app.css"
zopfli --i100 ./public/assets/css/app.css
brotli --force --quality=11 --output=./public/assets/css/app.css.br -- ./public/assets/css/app.css

echo "compressing js assets"
for file in ./public/assets/js/*.js
do
    zopfli --i100 $file
    brotli --force --quality=11 --output=$file.br -- $file
done

echo "compressing frontend assets"
for file in ./public/assets/frontend/*.css
do
    if [[ -f $file ]]; then
        zopfli --i100 $file
        brotli --force --quality=11 --output=$file.br -- $file
    fi
done
for file in ./public/assets/frontend/a11y.css/*.css
do
    if [[ -f $file ]]; then
        zopfli --i100 $file
        brotli --force --quality=11 --output=$file.br -- $file
    fi
done

echo "compressing highlight styles"
for file in ./public/assets/highlight/*.css
do
    if [[ -f $file ]]; then
        zopfli --i100 $file
        brotli --force --quality=11 --output=$file.br -- $file
    fi
done
