Minify, compress and put to an s3 bucket. It depends on awscli
#!/bin/bash
root=~/Projects/printuridigital.ro
src=$root/src
dist=$root/dist
what=$1
options_s3=$2
if [ -z $1 ]; then echo need file argument; exit; fi
type=${1##*.}
file_src=$src/$type/$what
file_min=$dist/$type/$what
file_gz=$dist/${type}gz/$what
case $type in
css|js)
if [ ! -f $file_src ]; then
echo $file_src is not a file
exit 1
fi
#minify
yui-compressor $file_src -v -o $file_min
gzip -9c $file_min > $file_gz
if [[ $options_s3 == --* ]]; then
if [[ "$options_s3" == "--aws" ]]; then
aws s3 cp --content-type text/css $file_min "s3://printuridigital.ro/"$type/$what
aws s3 cp --content-type text/css --content-encoding gzip $file_gz "s3://printuridigital.ro/"${type}gz/$what
else
eval "aws s3 cp $options_s3 --content-type text/css $file_min s3://printuridigital.ro/$type/$what"
eval "aws s3 cp $options_s3 --content-type text/css --content-encoding gzip $file_gz s3://printuridigital.ro/${type}gz/$what"
fi
fi
;;
*)
echo $type is unsupported
;;
esac