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
This commit is contained in:
Tim Buckley 2015-09-28 11:50:07 -06:00
parent 6ae7d8ace1
commit df8c054819
5 changed files with 25 additions and 3 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ stackviz/static/components/*
node_modules
build
app/js/templates.js
app/data
*.py[cod]
# C extensions

View File

@ -55,6 +55,11 @@ module.exports = {
'test': {
'karma': 'test/karma.conf.js',
'protractor': 'test/protractor.conf.js'
},
'data': {
'src' : ['app/data/**/*'],
'dest': 'build/data'
}
};

15
gulp/tasks/data.js Normal file
View File

@ -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 }));
});

View File

@ -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);
});
});

View File

@ -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']);
});
});