Skip to content

Instantly share code, notes, and snippets.

@lunaroja
Last active August 29, 2015 14:19
Show Gist options
  • Save lunaroja/420a1c26951b82197783 to your computer and use it in GitHub Desktop.
Save lunaroja/420a1c26951b82197783 to your computer and use it in GitHub Desktop.
Gulp file for Jekyll, Sass, Autoprefixer and BrowserSync
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var cp = require('child_process');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
gulp.task('sass', function () {
return gulp.src('_scss/main.scss')
.pipe(sass({
includePaths: ['scss'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8'], { cascade: true }))
.pipe(gulp.dest('assets/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('_site/assets/css'));
});
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
gulp.task('browser-sync', ['sass', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
gulp.task('watch', function () {
gulp.watch('_scss/*.scss', ['sass']);
gulp.watch(['**/*', '!_site/**', '!node_modules/**'], ['jekyll-rebuild']);
});
gulp.task('default', ['browser-sync', 'watch']);
{
"name": "username.github.io",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "User",
"license": "ISC",
"devDependencies": {
"gulp": "^3.8.8",
"gulp-sass": "^0.7.3",
"browser-sync": "^1.3.7",
"gulp-autoprefixer": "^1.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/username/username.github.io.git"
},
"keywords": [
"jekyll",
"gulp",
"sass",
"browsersync"
],
"bugs": {
"url": "https://github.com/username/username.github.io/issues"
},
"homepage": "https://github.com/username/username.github.io"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment