cyberdelia/django-pipeline — pull request #64 by UniIsland (2012-01-10 02:47:43+00:00)
Title: add support to output uncompiled .less css file

it's preferable to use less.js to load .less css files dynamically on a development site.

if PIPELINE is set to True, .less files are compiled and compressed the way you want.
if PIPELINE is False, .less files are output with in a link tag with rel='stylesheet/less'.
so less.js can recognize them.

this can't be done by modifying the less compiler class, since the compiler is not called when PIPELINE is set to False.

to use this feature. one should configure pipeline such that,

=== in django's settings.py ===

PIPELINE = not DEBUG

## don't compile .less file if PIPELINE is false
PIPELINE_COMPILERS = None if not PIPELINE else (
'pipeline.compilers.less.LessCompiler',
)

## put you .less files into the 'source_filenames' tuple as usual
#PIPELINE_CSS = { ... }

## use a list to hold you js 'source_filenames'
PIPELINE_JS_SOURCES = [
'vendors/jquery/jquery-1.6.1.min.js',
'path/of/your/script.js'
]

## add less.js to the list if PIPELINE is false
if not PIPELINE:
PIPELINE_JS_SOURCES.insert(0, 'vendors/lesscss/less-1.1.5.min.js')
## or
PIPELINE_JS_SOURCES.append('vendors/lesscss/less-1.1.5.min.js')

## convert to tuple when used in PIPELINE_JS
PIPELINE_JS = {
'all': {
'source_filenames': tuple(PIPELINE_JS_SOURCES),
'output_filename': 'js/script.r?.js',
},
}