From df8c054819ec9663529e52da83e87d978552023c Mon Sep 17 00:00:00 2001 From: Tim Buckley Date: Mon, 28 Sep 2015 11:50:07 -0600 Subject: [PATCH] Add `data` gulp task. This adds a new Gulp task to automatically include `app/data` in dev builds if it exists. This directory will contain sample data files for use during development and outputs them to `build/data`. Additionally, this integrates with browser-sync and will automatically reload open browsers as testing datasets are changed. Change-Id: Ie1578682d11e36bd6142b9d326f50a547aa4613b --- .gitignore | 1 + gulp/config.js | 5 +++++ gulp/tasks/data.js | 15 +++++++++++++++ gulp/tasks/development.js | 4 ++-- gulp/tasks/watch.js | 3 ++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gulp/tasks/data.js diff --git a/.gitignore b/.gitignore index 1c8fe82..5c468df 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ stackviz/static/components/* node_modules build app/js/templates.js +app/data *.py[cod] # C extensions diff --git a/gulp/config.js b/gulp/config.js index 2e9fe4d..23bb0b3 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -55,6 +55,11 @@ module.exports = { 'test': { 'karma': 'test/karma.conf.js', 'protractor': 'test/protractor.conf.js' + }, + + 'data': { + 'src' : ['app/data/**/*'], + 'dest': 'build/data' } }; diff --git a/gulp/tasks/data.js b/gulp/tasks/data.js new file mode 100644 index 0000000..f7e867d --- /dev/null +++ b/gulp/tasks/data.js @@ -0,0 +1,15 @@ +'use strict'; + +var config = require('../config'); +var changed = require('gulp-changed'); +var gulp = require('gulp'); +var browserSync = require('browser-sync'); + +gulp.task('data', function() { + + return gulp.src(config.data.src) + .pipe(changed(config.data.dest)) + .pipe(gulp.dest(config.data.dest)) + .pipe(browserSync.reload({ stream: true, once: true })); + +}); diff --git a/gulp/tasks/development.js b/gulp/tasks/development.js index cd00e83..747a368 100644 --- a/gulp/tasks/development.js +++ b/gulp/tasks/development.js @@ -9,6 +9,6 @@ gulp.task('dev', ['clean'], function(cb) { global.isProd = false; - runSequence(['styles', 'images', 'fonts', 'views', 'browserify'], 'watch', cb); + runSequence(['styles', 'images', 'fonts', 'data', 'views', 'browserify'], 'watch', cb); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index 36aa72c..e144a50 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -10,6 +10,7 @@ gulp.task('watch', ['browserSync', 'server'], function() { gulp.watch(config.styles.src, ['styles']); gulp.watch(config.images.src, ['images']); gulp.watch(config.fonts.src, ['fonts']); + gulp.watch(config.data.src, ['data']); gulp.watch(config.views.watch, ['views']); -}); \ No newline at end of file +});