Skip to content

Instantly share code, notes, and snippets.

@tkorakas
Created February 26, 2017 19:31
Show Gist options
  • Save tkorakas/1fdb37faa7de8d6c673d0d8f22e24d17 to your computer and use it in GitHub Desktop.
Save tkorakas/1fdb37faa7de8d6c673d0d8f22e24d17 to your computer and use it in GitHub Desktop.
Gulpfile for Sass compilation. Sourcemaps included.
'use strict';
const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
// Compile sass to css for dev.
gulp.task('sass:dev', function() {
return gulp.src('./sass/*.scss')
// Initializes sourcemaps.
.pipe(sourcemaps.init())
.pipe(sass.sync().on('error', sass.logError))
// Writes sourcemaps into the CSS file.
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'));
});
// Watch for file changes.
gulp.task('watch', function() {
gulp.watch('./sass/*.scss', ['sass']);
});
// Compile sass to css.
gulp.task('sass', function() {
return gulp.src('./sass/*.scss')
.pipe(sass.sync({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./css'));
});
// Default task.
gulp.task('default', ['sass:dev', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment