Skip to content

Instantly share code, notes, and snippets.

@grevory
Created November 3, 2013 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grevory/7287252 to your computer and use it in GitHub Desktop.
Save grevory/7287252 to your computer and use it in GitHub Desktop.
A simple script to compile CSS from LESS for a production environment
#!/bin/bash
LESSCSS="First parameter"
COMPILEDCSS=$2
if [ -z "$1" -o -z "$2" ]; then
echo "To use compile-css pass 1. less file 2. compiled css file"
fi
if [[ $1 ]]; then
LESSCSS=$1
fi
# The first parameter needs to be a file and needs to exist
if [[ -d $LESSCSS ]]; then
echo "$LESSCSS is a directory. Needs to be a file."
exit 1
elif [[ -f $LESSCSS ]]; then
echo "Compiling $LESSCSS..."
else
echo "$LESSCSS needs to be a file"
exit 1
fi
# If the second parameter is already a file we need to remove it
if [[ -f $PASSED ]]; then
rm $COMPILEDCSS
fi
lessc $LESSCSS > $COMPILEDCSS --yui-compress
echo "$COMPILEDCSS compiled"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment