2013-10-09 18:15:47 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
choices=0
|
2013-10-10 19:18:29 +02:00
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
if [ ! -n "$1" ]; then
|
|
|
|
echo 'no arguments passed.. this will simply convert LESS to CSS.'
|
|
|
|
echo "in case you're wondering, there's arguments you can pass:"
|
|
|
|
echo ' -m / --minify = minify css'
|
|
|
|
echo ' -p / --prefix = apply browser-specific prefixes'
|
|
|
|
echo ''
|
2013-10-10 19:18:29 +02:00
|
|
|
fi
|
2013-10-09 18:15:47 +02:00
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
|
2013-10-09 18:15:47 +02:00
|
|
|
if [ -n "$1" ]; then
|
|
|
|
if [ $1 = '--prefix' ] || [ $1 = '-p' ]; then
|
2013-10-12 12:13:33 +02:00
|
|
|
# echo 'got prefix'
|
|
|
|
choices=`expr $choices + 1`
|
2013-10-09 18:15:47 +02:00
|
|
|
fi
|
2013-10-10 19:18:29 +02:00
|
|
|
if [ $1 = '--minify' ] || [ $1 = '-m' ]; then
|
2013-10-12 12:13:33 +02:00
|
|
|
# echo 'got minify'
|
|
|
|
choices=`expr $choices + 2`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -n "$2" ]; then
|
|
|
|
if [ $2 = '--prefix' ] || [ $2 = '-p' ]; then
|
|
|
|
# echo 'got prefix'
|
|
|
|
choices=`expr $choices + 1`
|
|
|
|
fi
|
|
|
|
if [ $2 = '--minify' ] || [ $2 = '-m' ]; then
|
|
|
|
# echo 'got minify'
|
|
|
|
choices=`expr $choices + 2`
|
2013-10-09 18:15:47 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
if [ -a css/styles.min.css ]; then
|
|
|
|
rm css/styles.min.css
|
|
|
|
fi
|
2013-10-09 18:15:47 +02:00
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
# generate CSS from LESS
|
|
|
|
echo 'converting LESS to CSS...'
|
|
|
|
lessc less/styles.less css/styles.css
|
2013-10-09 18:15:47 +02:00
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
case "$choices" in
|
|
|
|
"0")
|
|
|
|
echo 'just less-to-css'
|
|
|
|
;;
|
|
|
|
"1")
|
|
|
|
echo 'applying prefixr...'
|
2013-10-09 18:15:47 +02:00
|
|
|
# prefixed (-s overwrites existing file)
|
|
|
|
prefixr --input ./css/styles.css -s
|
2013-10-12 12:13:33 +02:00
|
|
|
;;
|
|
|
|
"2")
|
|
|
|
echo 'creating minified....'
|
|
|
|
lessc --yui-compress less/styles.less css/styles.min.css
|
|
|
|
;;
|
|
|
|
"3")
|
2013-10-09 18:15:47 +02:00
|
|
|
echo 'creating minified and prefixed...'
|
|
|
|
|
2013-10-12 12:13:33 +02:00
|
|
|
# prefixed (-s overwrites existing file)
|
|
|
|
prefixr --input ./css/styles.css -s
|
|
|
|
|
2013-10-09 18:15:47 +02:00
|
|
|
# copy to .min.css to create a minified version as well
|
|
|
|
cp css/styles.css css/styles.min.css
|
|
|
|
|
|
|
|
# prefixed and minified (-s overwrites existing file)
|
|
|
|
prefixr --input ./css/styles.min.css -s -c
|
2013-10-12 12:13:33 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo 'catch-all'
|
|
|
|
;;
|
|
|
|
esac
|