#!/bin/bash
echo Building...
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

echo ' Compiling lib JS files...'
./minify-libs

echo ' Minifying lib CSS files...'
cd ../lib/css/
cat bootstrap.min.css > combined.css
cat font-awesome.min.css >> combined.css
cat jquery-ui.min.css >> combined.css
cat spectrum.css >> combined.css
curl -X POST -s --data-urlencode 'input@combined.css' http://cssminifier.com/raw > combined.min.css
rm combined.css
cd ../../build/

echo ' Compiling app JS files...'
./minify-app

echo ' Minifying app CSS files...'
cd ../css/
curl -X POST -s --data-urlencode 'input@styles.css' http://cssminifier.com/raw > styles.min.css
cd ../build/

echo ' Updating index.html...'
cd ../
if [ -f indexProd.html ]; then
    mv index.html indexDev.html
    mv indexProd.html index.html
fi
cd build/

echo Build Complete
