Gulp for Sitebuilds

December 25, 2014 at 4:00PM

Gulp, is a tiny library of utility functions (src, dest, task, and watch) that plug and play nicely with node streams. As such, if your a stream fan, or simply have ever used Unix pipes, Gulp will make you feel right at home while helping you to architect sitebuilds.

As far as Gulpfile's go, structure your tasks, or task-generating logic however you wish. What I found to work for me on the sitebuild for userbound.com was to break my logic into small exports-style modules and let my Gulpfile play the role of master require-er:

#!/usr/bin/env node
'use strict';
// Require Modules
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({
  pattern: '*',
  rename: {
    'underscore': '_',
    'yaml-front-matter': 'yaml_extractor',
    'gulp-front-matter': 'fem',
    'gulp-ruby-sass': 'sass'
  }
});

// Require Globals (vars) and Utils (fns)
var globals = require('./lib/globals')($);
var util    = require('./lib/util')($, globals);
var mutators = require('./lib/mutators')($, globals);

// Require Tasks 
$._.each($.fs.readdirSync('./lib/tasks'), function(module) { 
  require('./lib/tasks/' + module)(gulp, $, util, mutators, globals); 
});

This way, I keep my tasks nice, small, and discrete. Jekyll for sitebuilds always felt like a hack; but Gulp for sitebuilds feels great.

Thanks Gulp.