Created
April 17, 2015 08:07
-
-
Save adamledwards/8b81fcd0c8b8ce05a6e8 to your computer and use it in GitHub Desktop.
jekyll and gulp
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 gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var livereload = require('gulp-livereload'); | |
var prefix = require('gulp-autoprefixer'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var runSequence = require('run-sequence'); | |
gulp.task('sass', function () { | |
gulp.src('./assets/css/*.scss') | |
.pipe(sourcemaps.init()) | |
.pipe(sass( | |
{ | |
outputStyle: 'compressed', | |
sourceComments: 'map', | |
errLogToConsole: true, | |
includePaths: ['./_sass'] | |
} | |
)) | |
.pipe(prefix("last 4 version")) | |
.pipe(sourcemaps.write('./maps')) | |
.pipe(gulp.dest('./_site/assets/css/')) | |
.pipe(livereload()); | |
}); | |
gulp.task('watch', function() { | |
livereload.listen(); | |
gulp.watch('./assets/css/*.{scss,sass}', ['sass']); | |
gulp.watch('./_sass/*.{scss,sass}', ['sass']); | |
gulp.watch('./assets/**/*.{js,png,jpg}', ['build']); | |
gulp.watch('./*.html', ['build']); | |
}); | |
// The default task (called when you run `gulp` from cli) | |
gulp.task('default', ['watch'], function(){ | |
var spawn = require('child_process').spawn; | |
var jekyll = spawn('jekyll', ['serve', '--no-watch'], {stdio: 'inherit'}); | |
}); | |
gulp.task('jekyll-build', function (gulpCallBack){ | |
var spawn = require('child_process').spawn; | |
var jekyll = spawn('jekyll', ['build'], {stdio: 'inherit'}); | |
jekyll.on('exit', function(code) { | |
gulpCallBack(code === 0 ? null : 'ERROR: Jekyll process exited with code: '+code); | |
}); | |
}); | |
gulp.task('build', function(callback){ | |
runSequence('jekyll-build', | |
['sass'], | |
callback); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment