Skip to content

Instantly share code, notes, and snippets.

@M-Drummond
Last active March 30, 2016 00:28
Show Gist options
  • Save M-Drummond/eab67f622f42b8bd4a66f226dfe4c6ad to your computer and use it in GitHub Desktop.
Save M-Drummond/eab67f622f42b8bd4a66f226dfe4c6ad to your computer and use it in GitHub Desktop.
Simple Sass + Watch Gulpfile
var gulp = require('gulp');
var sass = require('gulp-sass');
var input = '*.scss';
var output = '';
gulp.task('sass', function () {
return gulp
// Find all `.scss` files from the `stylesheets/` folder
.src(input)
// Run Sass on those files
.pipe(sass())
// Write the resulting CSS in the output folder
.pipe(gulp.dest(output));
});
gulp.task('watch', function() {
return gulp
// Watch the input folder for change,
// and run `sass` task when something happens
.watch(input, ['sass'])
// When there is a change,
// log a message in the console
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
});
});
var sassOptions = {
errLogToConsole: true,
outputStyle: 'expanded'
};
gulp.task('sass', function () {
return gulp
.src(input)
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(gulp.dest(output));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment