Skip to content

Instantly share code, notes, and snippets.

@selahattinunlu
Created February 12, 2016 16:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save selahattinunlu/a4feda575ced84768bb3 to your computer and use it in GitHub Desktop.
Save selahattinunlu/a4feda575ced84768bb3 to your computer and use it in GitHub Desktop.
Basic Gulpfile - Sass
var gulp = require('gulp'),
sass = require('gulp-sass');
var sassConfig = {
inputDirectory: 'resources/sass/**/*.scss',
outputDirectory: 'assets/css',
options: {
outputStyle: 'expanded'
}
}
gulp.task('build-css', function() {
return gulp
.src(sassOptions.inputDirectory)
.pipe(sass(sassConfig.options).on('error', sass.logError))
.pipe(gulp.dest(sassConfig.outputDirectory);
});
gulp.task('watch', function() {
gulp.watch('resources/sass/**/*.scss', ['build-css']);
});
@charneykaye
Copy link

Thanks! This is great. Note missing final parens on line 16. Also I added a default task:

// Default Task
gulp.task('default', ['build-css']);

@cchoe1
Copy link

cchoe1 commented Feb 15, 2019

Line 14: should be sassConfig, not sassOptions.

Also charneykaye's comment is relevant.

Also, if you are running Gulp 4.x, you will want to change Line 20 to be something like:

gulp.watch('path/to/watch', gulp.series('build-css'))

Other than those small things, this is a very good base for a front-end newb like myself to get a gulpfile off the ground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment