Created
July 24, 2011 13:06
-
-
Save remcoder/1102600 to your computer and use it in GitHub Desktop.
Compile LESS to CSS automatically whenever a file is modified
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
#!/usr/bin/env python | |
# determines filename and extension, then delegates compiling the LESS files to lessc via a shell command | |
import sys, os.path | |
from subprocess import call | |
src = sys.argv[1] | |
base,ext = os.path.splitext(src) | |
dest = base + ".css" | |
cmd = "lessc %s > %s" % (src , dest) | |
#print cmd | |
print "%s -> %s" % (os.path.split(src)[1], os.path.split(dest)[1]) | |
call( cmd , shell=True) |
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 | |
# Compile LESS to CSS automatically whenever a file is modified | |
# requirements | |
# | |
# 1 the LESS compiler (lessc) | |
# - first you need Node.js, download it at http://nodejs.org/ | |
# - then install npm from http://npmjs.org/ | |
# - then install LESS: | |
# | |
# $ npm install less | |
# | |
# 2 Watchdog | |
# - requires Python | |
# - install via easy_install: | |
# | |
# $ sudo easy_install Watchdog | |
# | |
# NOTE: we'll be using the 'watchmedo' script included with Watchdog | |
# | |
# 3 make sure both 'watchmedo' and 'lessc' are in your PATH | |
# | |
# 4 from the directory containing your LESS file, run this command: | |
# | |
# $ ./watch_less.sh | |
# | |
echo "Watching folder `pwd`" | |
watchmedo shell-command --patterns="*.less" --command='./build_less.py ${watch_src_path} ' . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment