Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
Created September 11, 2017 21:34
Show Gist options
  • Save lumpysimon/cf9887c63a345d1f933eafad45894970 to your computer and use it in GitHub Desktop.
Save lumpysimon/cf9887c63a345d1f933eafad45894970 to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
sourcemaps = require('gulp-sourcemaps'),
livereload = require('gulp-livereload'),
input = {
'sass': [
'sass/**/*.scss'
]
},
output = {
'stylesheets': '.'
},
sassOpts = {
errLogToConsole: true,
outputStyle: 'compressed'
};
/* run the watch task when gulp is called without arguments */
gulp.task('default', ['build-css','watch']);
/* compile scss files */
gulp.task('build-css', function() {
gulp
.src(input.sass)
.pipe(sourcemaps.init())
.pipe(sass(sassOpts).on('error',sass.logError))
.pipe(prefix("last 2 versions"))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(output.stylesheets))
.pipe(livereload());
});
/* Watch these files for changes and run the task on update */
gulp.task('watch', function() {
livereload.listen();
gulp.watch(input.sass, ['build-css']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment