chore(demos): don't bundle demos when developing

Rebundling all demos on every change takes 1 minute, only do it for
production.
This commit is contained in:
Tim Lancina
2016-02-18 14:51:55 -06:00
parent 87364db977
commit 1b7cb8ccb0
4 changed files with 67 additions and 13 deletions

View File

@ -485,10 +485,22 @@ gulp.task('tests', function() {
* Builds Ionic demos to dist/demos, copies them to ../ionic-site and watches
* for changes.
*/
gulp.task('watch.demos', ['demos'], function() {
watch('demos/**/*', function() {
gulp.start('demos');
});
//TODO, decide on workflow for site demos (dev and prod), vs local dev (in dist)
var LOCAL_DEMOS = false;
gulp.task('watch.demos', function(done) {
LOCAL_DEMOS = true;
runSequence(
['build.demos', 'transpile', 'copy.libs', 'sass', 'fonts'],
function(){
watchTask('bundle.system');
watch('demos/**/*', function(file) {
gulp.start('build.demos');
});
done();
}
);
});
/**
@ -510,6 +522,10 @@ gulp.task('demos', ['bundle.demos'], function() {
return merge([demosStream, cssStream]);
});
gulp.task('demos.dev', function() {
});
/**
* Builds necessary files for each demo then bundles them using webpack. Unlike
* e2e tests, demos are bundled for performance (but have a slower build).
@ -560,10 +576,10 @@ gulp.task('build.demos', function() {
var fs = require('fs');
var VinylFile = require('vinyl');
var baseIndexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))();
var flags = minimist(process.argv.slice(2), flagConfig);
var indexTemplateName = LOCAL_DEMOS ? 'index.template.dev.html' : 'index.template.html';
var baseIndexTemplate = _.template(fs.readFileSync('scripts/demos/' + indexTemplateName))();
if ("production" in flags) {
if (flags.production) {
buildDemoSass(true);
} else {
buildDemoSass(false);