-
-
Save innermond/c05dae54ced7b8018629 to your computer and use it in GitHub Desktop.
Minify, compress and put to an s3 bucket. It depends on awscli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment