Skip to content

Instantly share code, notes, and snippets.

@dkrnl
Created February 8, 2015 10:36
Show Gist options
  • Save dkrnl/c5cb5e3bac9486ab8831 to your computer and use it in GitHub Desktop.
Save dkrnl/c5cb5e3bac9486ab8831 to your computer and use it in GitHub Desktop.
django-pipeline + less + glue
import os
from django.conf import settings
from pipeline.compilers import SubProcessCompiler
class LessCompiler(SubProcessCompiler):
output_extension = "css"
def match_file(self, filename):
return filename.endswith(".less")
def compile_file(self, infile, outfile, outdated=False, force=False):
command = [
settings.GLUE_BINARY,
settings.GLUE_SOURCE,
"--output=%s" % settings.GLUE_OUTPUT,
"--less",
]
self.execute_command(command)
infile = infile.strip("'")
outfile = outfile.strip("'")
command = [
settings.PIPELINE_LESS_BINARY,
infile,
outfile,
]
if settings.DEBUG:
command.append("--source-map=%s.map" % outfile)
command.append("--source-map-less-inline")
else:
command.append("--compress")
return self.execute_command(command, cwd=os.path.dirname(infile))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment