Created
November 13, 2015 20:03
-
-
Save ritcheyer/c28bff8ae02ce755da5c to your computer and use it in GitHub Desktop.
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
var path = require('path'), | |
gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
notify = require('gulp-notify'), | |
plumber = require('gulp-plumber'), | |
sourcemaps = require('gulp-sourcemaps'), | |
livereload = require('gulp-livereload'), | |
paths = [ | |
'./node_modules/breakpoint-sass/stylesheets', | |
'./node_modules/susy/sass', | |
'./node_modules/bourbon/app/assets/stylesheets', | |
], | |
notifier_icon = path.join(__dirname, 'sites_d7/all/themes/custom/tesla_theme/assets/img/logo-inverted.png'); | |
// Compile for developers | |
gulp.task('dev sass: compile theme', function() { | |
var onError = function (error) { | |
var lineNumber = (error.line) ? 'LINE ' + error.line + ' -- ' : ''; | |
notify({ | |
title: 'Jarvis', | |
subtitle: 'Task Failed [' + error.plugin + ']', | |
message: lineNumber + 'See console.', | |
icon: notifier_icon, | |
sound: 'Sosumi' | |
}).write(error); | |
console.log(error); | |
this.emit('end'); | |
}; | |
// gulp.src locates the source files for the process. This globbing function | |
// tells gulp to use all the files ending with .scss within the scss folder. | |
gulp.src('./sites_d7/all/themes/custom/tesla_theme/scss/**/*.scss') | |
.pipe(plumber({errorHandler: onError})) | |
// Initialize Sourcemaps | |
.pipe(sourcemaps.init()) | |
// Convert Sass into CSS with Gulp Sass | |
.pipe(sass({ | |
errLogToConsole: true, | |
includePaths: paths | |
})) | |
// Write the Sourcemaps into the CSS file | |
.pipe(sourcemaps.write()) | |
// Outputs CSS files in the CSS folder | |
.pipe(gulp.dest('./sites_d7/all/themes/custom/tesla_theme/css')) | |
}); | |
// Watch SCSS folder for changes | |
gulp.task('watching: theme', function() { | |
// Watches the SCSS folder for all *.scss files | |
// for changes, then runs the `sass` task | |
gulp.watch('./sites_d7/all/themes/custom/tesla_theme/scss/**/*.scss', ['dev sass: compile theme']) | |
}); | |
// Compile things for Developer environments | |
gulp.task('default', ['dev sass: compile theme', 'watching: theme']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment