Skip to content

Instantly share code, notes, and snippets.

@poksme
Created February 2, 2016 03:50

Revisions

  1. poksme created this gist Feb 2, 2016.
    53 changes: 53 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    /* global __filename */
    var gulp = require('gulp');
    var jade = require('gulp-jade');
    var less = require('gulp-less');
    var serve = require('gulp-serve');
    var open = require('gulp-open');
    var livereload = require('gulp-livereload');

    gulp.task('build-templates', function() {
    var locals = {};

    return gulp.src('./templates/**/*.jade')
    .pipe(jade({
    locals: locals
    }))
    .pipe(gulp.dest('./public/'))
    .pipe(livereload());
    });

    gulp.task('build-styles', function () {
    return gulp.src('./styles/**/*.less')
    .pipe(less({}))
    .pipe(gulp.dest('./public/stylesheets'));
    });

    gulp.task('serve', serve('./public/'));

    gulp.task('open', function () {
    return gulp.src(__filename)
    .pipe(open({uri: 'http://localhost:3000'}));
    });

    gulp.task('init-watch', function () {
    return livereload.listen({ basePath: 'public' });
    });

    gulp.task('watch-styles', ['init-watch'], function () {
    return gulp.watch('styles/**/*.less', ['build-styles']);
    });

    gulp.task('watch-templates', ['init-watch'], function () {
    return gulp.watch('templates/**/*.jade', ['build-templates']);
    });

    gulp.task('watch-content', ['init-watch'], function () {
    return gulp.watch('content/**/*.md', ['build-templates']);
    });

    gulp.task('build', ['build-templates', 'build-styles']);

    gulp.task('watch', ['watch-templates', 'watch-styles', 'watch-content']);

    gulp.task('default', ['build', 'serve', 'open', 'watch']);