Skip to content

Instantly share code, notes, and snippets.

@fubhy
Created June 30, 2014 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fubhy/e9b486f160fc6743267e to your computer and use it in GitHub Desktop.
Save fubhy/e9b486f160fc6743267e to your computer and use it in GitHub Desktop.
Compass and LibSass
# Convert .scss to .css (including live reload). In some cases (e.g. when using
# Compass) the 'images' task has to run before this one so that utility
# functions like 'image-url' don't cause errors when evaluated before the image
# has been created.
gulp.task 'styles', ['images'], ->
sassConfig =
outputStyle: if isProduction then 'compressed' else 'expanded'
# Source maps are currently broken in 'gulp-sass'.
#sourceComments: 'map'
compassConfig =
sass: 'src/sass',
css: 'dist/css',
image: 'dist/images',
bundle_exec: true,
require: ['toolkit', 'singularitygs']
# Compile the .scss and catch (and log) any potential errors so the pipe does
# not break.
sassStream = gulp.src(paths.sass)
.pipe(sass sassConfig)
.on('error', util.log)
.on('error', util.beep)
if useCompass
compassStream = gulp.src(paths.compass)
.pipe(compass compassConfig)
.on('error', util.log)
.on('error', util.beep)
sassStream = merge(sassStream, compassStream)
# Automatically add vendor prefixes.
sassStream.pipe(prefix ['last 2 version', '> 1%'], map: false)
# Write the compiled .css files and reload.
sassStream.pipe(gulp.dest 'dist/css')
.pipe(livereload server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment