Commit c13e6230 by David Ormsbee Committed by Andy Armstrong

Speed up SASS compilation with libsass

parent dce3d9ca
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
@return false; @return false;
} }
@mixin directional-property($pre, $suf, $vals) { @mixin directional-property($pre, $suf, $vals...) {
// Property Names // Property Names
$top: $pre + "-top" + if($suf, "-#{$suf}", ""); $top: $pre + "-top" + if($suf, "-#{$suf}", "");
$bottom: $pre + "-bottom" + if($suf, "-#{$suf}", ""); $bottom: $pre + "-bottom" + if($suf, "-#{$suf}", "");
......
...@@ -3,7 +3,7 @@ Asset compilation and collection. ...@@ -3,7 +3,7 @@ Asset compilation and collection.
""" """
from __future__ import print_function from __future__ import print_function
from datetime import datetime
import argparse import argparse
import glob import glob
import traceback import traceback
...@@ -12,6 +12,7 @@ from paver import tasks ...@@ -12,6 +12,7 @@ from paver import tasks
from paver.easy import sh, path, task, cmdopts, needs, consume_args, call_task, no_help from paver.easy import sh, path, task, cmdopts, needs, consume_args, call_task, no_help
from watchdog.observers import Observer from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler from watchdog.events import PatternMatchingEventHandler
import sass
from .utils.envs import Env from .utils.envs import Env
from .utils.cmd import cmd, django_cmd from .utils.cmd import cmd, django_cmd
...@@ -192,30 +193,31 @@ def compile_sass(options): ...@@ -192,30 +193,31 @@ def compile_sass(options):
Compile Sass to CSS. Compile Sass to CSS.
""" """
debug = options.get('debug') debug = options.get('debug')
parts = ["sass"]
parts.append("--update")
parts.append("--cache-location {cache}".format(cache=SASS_CACHE_PATH))
parts.append("--default-encoding utf-8")
if debug: if debug:
parts.append("--sourcemap") source_comments = True
output_style = 'nested'
else: else:
parts.append("--style compressed --quiet") source_comments = False
if options.get('force'): output_style = 'compressed'
parts.append("--force")
parts.append("--load-path .") timing_info = []
for load_path in SASS_LOAD_PATHS + SASS_DIRS:
parts.append("--load-path {path}".format(path=load_path))
for sass_dir in SASS_DIRS: for sass_dir in SASS_DIRS:
start = datetime.now()
css_dir = sass_dir.parent / "css" css_dir = sass_dir.parent / "css"
if css_dir: sass.compile(
parts.append("{sass}:{css}".format(sass=sass_dir, css=css_dir)) dirname=(sass_dir, css_dir),
else: include_paths=SASS_LOAD_PATHS + SASS_DIRS,
parts.append(sass_dir) source_comments=source_comments,
output_style=output_style,
sh(cmd(*parts)) )
duration = datetime.now() - start
print("\t\tFinished compiling sass.") timing_info.append((sass_dir, css_dir, duration))
print("\t\tFinished compiling Sass:")
for sass_dir, css_dir, duration in timing_info:
print(">> {} -> {} in {}s".format(sass_dir, css_dir, duration))
def compile_templated_sass(systems, settings): def compile_templated_sass(systems, settings):
......
...@@ -5,3 +5,4 @@ lazy==1.1 ...@@ -5,3 +5,4 @@ lazy==1.1
path.py==7.2 path.py==7.2
watchdog==0.7.1 watchdog==0.7.1
python-memcached python-memcached
libsass==0.10.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment