/ Published in: Bash
When bound to cmd+s in textmate this can compile your LESS CSS files and output a CSS file.
For large projects I use a watch script which checks the SCM flag of all the less files in the project and then compiles those that need to be updated. Compiling 20+ less files can take a second or two, watch.bash eliminates that delay.
Expand |
Embed | Plain Text
compile_less() { ORIGINAL_FILE="$1" CSS_FILE=${ORIGINAL_FILE/less/css} lessc ${ORIGINAL_FILE} ${CSS_FILE} # check if file is empty if [[ ! -s ${CSS_FILE} ]]; then rm ${CSS_FILE} &> /dev/null fi } if [[ ${TM_FILEPATH} == *.less ]]; then compile_less $TM_FILEPATH lessFileName=`basename ${TM_FILEPATH}` fgrep -r --include="*.less" $lessFileName $TM_PROJECT_DIRECTORY | while read line; do compile_less ${line%%:@import*} done fi
You need to login to post a comment.
