Created
February 26, 2017 19:31
-
-
Save tkorakas/1fdb37faa7de8d6c673d0d8f22e24d17 to your computer and use it in GitHub Desktop.
Gulpfile for Sass compilation. Sourcemaps included.
This file contains 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
'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