var gulp = require('gulp');
var browserify = require('browserify');
var transform = require('vinyl-transform');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');

var paths = {
  index: "./demo.js",
  html: "./index.html",
  deploy: "/srv/http/tom.shea.at/desktopical-demo/",
  windowsill_dev: "../windowsill/**/*",
  desktopical_dev: "../desktopical/**/*"
};

function onError(err) {
  console.error(err.toString());
  this.emit('end');
}

gulp.task('browserify', function() {
  var browserifyTransform = transform(function(filename) {
    var b = browserify({entries: filename, debug:true});
    return b.bundle();
  });

  return gulp.src(paths.index)
    .pipe(browserifyTransform)
    .on('error', onError)
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('./build'));
});

gulp.task('watch', function() {
  gulp.watch([paths.index, paths.windowsill_dev, paths.desktopical_dev], ['deploy-js']);
  gulp.watch([paths.html], ['deploy-static']);
});

gulp.task('deploy-js', ['browserify'], function() {
  gulp.src('./build/*')
    .pipe(gulp.dest(paths.deploy));
});

gulp.task('deploy-static', function() {
  gulp.src(paths.html)
    .pipe(gulp.dest(paths.deploy));
});

gulp.task('deploy', ['deploy-js', 'deploy-static']);

gulp.task('default', ['browserify']);

@@ -248,16 +248,37 @@
 .html%22,%0A
+  images: %22./*.png%22,%0A
   deploy
@@ -334,24 +334,27 @@
 ndowsill_dev
+_js
 : %22../window
@@ -362,16 +362,70 @@
 ill/**/*
+.js%22,%0A  windowsill_dev_static: %22../windowsill/**/*.css
 %22,%0A  des
@@ -436,16 +436,19 @@
 ical_dev
+_js
 : %22../de
@@ -461,16 +461,72 @@
 cal/**/*
+.js%22,%0A  desktopical_dev_static: %22../desktopical/**/*.css
 %22%0A%7D;%0A%0Afu
@@ -1086,16 +1086,19 @@
 sill_dev
+_js
 , paths.
@@ -1112,16 +1112,19 @@
 ical_dev
+_js
 %5D, %5B'dep
@@ -1158,16 +1158,75 @@
 ths.html
+, paths.windowsill_dev_static, paths.desktopical_dev_static
 %5D, %5B'dep
@@ -1409,24 +1409,25 @@
 %0A  gulp.src(
+%5B
 paths.html)%0A
@@ -1424,16 +1424,90 @@
 ths.html
+, paths.images, paths.desktopical_dev_static, paths.windowsill_dev_static%5D
 )%0A    .p

Split paths into static vs js for dev packages