Last active
August 29, 2015 14:12
-
-
Save tristola/07a8e8d72cd633f79867 to your computer and use it in GitHub Desktop.
simple web project with templating
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 data = require('gulp-data'); | |
var path = require('path'); | |
var jade = require('gulp-jade'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
gulp.task('default',['jade','browser-sync'], function () { | |
gulp.watch("templates/*.jade", ['jade']); | |
}); | |
// Using templates with data from data folder | |
gulp.task('jade', function() { | |
gulp.src('./templates/*.jade') | |
.pipe(data(function(file) { | |
return require('./data/' + path.basename(file.path) + '.json'); | |
})) | |
.pipe(jade({ | |
pretty: true | |
})) | |
.pipe(gulp.dest('public/')) | |
.pipe(browserSync.reload({stream: true})); | |
}); | |
// Static server | |
gulp.task('browser-sync', function() { | |
browserSync({ | |
server: { | |
baseDir: "./public" | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment