Commit c13e6230 by David Ormsbee Committed by Andy Armstrong

Speed up SASS compilation with libsass

parent dce3d9ca
......@@ -49,7 +49,7 @@
@return false;
}
@mixin directional-property($pre, $suf, $vals) {
@mixin directional-property($pre, $suf, $vals...) {
// Property Names
$top: $pre + "-top" + if($suf, "-#{$suf}", "");
$bottom: $pre + "-bottom" + if($suf, "-#{$suf}", "");
......
......@@ -3,7 +3,7 @@ Asset compilation and collection.
"""
from __future__ import print_function
from datetime import datetime
import argparse
import glob
import traceback
......@@ -12,6 +12,7 @@ from paver import tasks
from paver.easy import sh, path, task, cmdopts, needs, consume_args, call_task, no_help
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
import sass
from .utils.envs import Env
from .utils.cmd import cmd, django_cmd
......@@ -192,30 +193,31 @@ def compile_sass(options):
Compile Sass to CSS.
"""
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:
parts.append("--sourcemap")
source_comments = True
output_style = 'nested'
else:
parts.append("--style compressed --quiet")
if options.get('force'):
parts.append("--force")
parts.append("--load-path .")
for load_path in SASS_LOAD_PATHS + SASS_DIRS:
parts.append("--load-path {path}".format(path=load_path))
source_comments = False
output_style = 'compressed'
timing_info = []
for sass_dir in SASS_DIRS:
start = datetime.now()
css_dir = sass_dir.parent / "css"
if css_dir:
parts.append("{sass}:{css}".format(sass=sass_dir, css=css_dir))
else:
parts.append(sass_dir)
sh(cmd(*parts))
print("\t\tFinished compiling sass.")
sass.compile(
dirname=(sass_dir, css_dir),
include_paths=SASS_LOAD_PATHS + SASS_DIRS,
source_comments=source_comments,
output_style=output_style,
)
duration = datetime.now() - start
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):
......
......@@ -5,3 +5,4 @@ lazy==1.1
path.py==7.2
watchdog==0.7.1
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