Created
February 8, 2015 10:36
-
-
Save dkrnl/c5cb5e3bac9486ab8831 to your computer and use it in GitHub Desktop.
django-pipeline + less + glue
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
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