Created
October 27, 2017 23:05
-
-
Save isaacdanielanderson/ea29f26059765f09d3def802506ad02f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var input = './styles/**/*.scss'; | |
var output = './styles/'; | |
// SASS options | |
var sassOptions = { | |
errLogToConsole: true, | |
outputStyle: 'compressed' | |
}; | |
// Autoprefixer options | |
var autoprefixerOptions = { | |
browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] | |
}; | |
gulp.task('sass', function () { | |
return gulp | |
.src(input) | |
.pipe(sourcemaps.init()) // Sourcemaps are for viewing where styles are located in the inspector tool | |
.pipe(sass(sassOptions).on('error', sass.logError)) | |
.pipe(sourcemaps.write()) | |
.pipe(autoprefixer(autoprefixerOptions)) | |
.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...'); | |
}); | |
}); | |
gulp.task('default', ['sass', 'watch' /*, possible other tasks... */]); | |
// Courtesy of Hugo: https://www.sitepoint.com/simple-gulpy-workflow-sass/ Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment