text: var gulp = require('gulp');
  var source = require('vinyl-source-stream');
  var concat = require('gulp-concat');
  var browserify = require('browserify');
  var uglify = require('gulp-uglify');
  var utilities = require('gulp-util');
  var del = require('del');
  var browserSync = require('browser-sync').create();
  var shell = require('gulp-shell');
  var sass = require('gulp-sass');
  var sourcemaps = require('gulp-sourcemaps');
  var lib = require('bower-files')({
    "overrides":{
      "bootstrap" : {
        "main": [
          "less/bootstrap.less",
          "dist/css/bootstrap.css",
          "dist/js/bootstrap.js"
        ]
      }
    }
  });
  var buildProduction = utilities.env.production;
  
  ////////////////////// TYPESCRIPT //////////////////////
  
  
  gulp.task('tsClean', function(){
    return del(['app/*.js', 'app/*.js.map']);
  });
  
  gulp.task('ts', ['tsClean'], shell.task([
    'tsc'
  ]));
  
  ////////////////////// BOWER //////////////////////
  
  
  gulp.task('jsBowerClean', function(){
    return del(['./build/js/vendor.min.js']);
  });
  
  gulp.task('jsBower', ['jsBowerClean'], function() {
    return gulp.src(lib.ext('js').files)
      .pipe(concat('vendor.min.js'))
      .pipe(uglify())
      .pipe(gulp.dest('./build/js'));
  });
  
  gulp.task('cssBowerClean', function(){
    return del(['./build/css/vendor.css']);
  });
  
  gulp.task('cssBower', ['cssBowerClean'], function() {
    return gulp.src(lib.ext('css').files)
      .pipe(concat('vendor.css'))
      .pipe(gulp.dest('./build/css'));
  });
  
  gulp.task('bower', ['jsBower', 'cssBower']);
  
  ////////////////////// SASS //////////////////////
  
  gulp.task('sassBuild', function() {
    return gulp.src(['scss/*'])
      .pipe(sourcemaps.init())
      .pipe(sass())
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('./build/css'));
  });
  
  ////////////////////// SERVER //////////////////////
  
  
  gulp.task('serve', ['build'], function() {
    browserSync.init({
      server: {
        baseDir: "./",
        index: "index.html"
      }
    });
    gulp.watch(['resources/js/*.js'], ['jsBuild']); // vanilla js changes, reload.
    gulp.watch(['*.html'], ['htmlBuild']); // html changes, reload.
    gulp.watch(['css/*.css', 'scss/*.scss'], ['cssBuild']);
    gulp.watch(['app/*.ts'], ['tsBuild']); // typescript files change, compile then reload.
  });
  
  gulp.task('jsBuild', function(){
    browserSync.reload();
  });
  
  gulp.task('htmlBuild', function(){
    browserSync.reload();
  });
  
  gulp.task('cssBuild', ['sassBuild'], function(){
    browserSync.reload();
  });
  
  gulp.task('tsBuild', ['ts'], function(){
    browserSync.reload();
  });
  
  ////////////////////// GLOBAL BUILD TASK //////////////////////
  
  gulp.task('build', ['ts'], function(){
    // we can use the buildProduction environment variable here later.
    gulp.start('bower');
    gulp.start('sassBuild');
  });
  