// Load Gulp plugin
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var autoprefixer = require('gulp-autoprefixer');
var eslint = require('gulp-eslint');
var csscomb = require('gulp-csscomb');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var minifyCss = require('gulp-minify-css');
var babel = require("gulp-babel");
var eslint = require('eslint/lib/cli');
var globby = require('globby');

//Sass(Scss) Task (Development Only)
gulp.task('compile:Sass', function () {
  gulp.src('./src/sass/**/*.scss')
    .pipe(sass.sync().on('error', sass.logError))
    .pipe(autoprefixer({
            browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'],
            cascade: false
        }))
        .pipe(csscomb())
        .pipe(gulp.dest('./src/css'));
});

//Minify CSS Task (Production Only)
gulp.task('minify:css',function(){
	 gulp.src('./src/css/*.css')
			   .pipe(minifyCss())
			   .pipe(gulp.dest('./build/css/'))
	});

// Babel Task (Production)
gulp.task('babel:js',function () {
	gulp.src('./src/js/**/*.js')
	.pipe(babel())
  .pipe(gulp.dest("dist"));
});



//lint and minify JS Task (Development)
gulp.task('eslint',function(){
		return gulp.src(['./src/js/**/*.js'])
		.pipe(eslint())
		.pipe(eslint.format())
		.pipe(eslint.failOnError())
		.pipe(uglify())
		.pipe(gulp.dest('./build/js/*.js'));
	});

  // patterns with the same form as gulp.src(patterns)
  var patterns = ['lib/**/*.{js}'];

  globby(patterns, function(err, paths) {
    if (err) {
      // unexpected failure, include stack
      done(err);
      return;
    }
    // additional CLI options can be added here
    var code = eslint.execute(paths.join(' '));
    if (code) {
      // eslint output already written, wrap up with a short message
      done(new gutil.PluginError('lint', new Error('ESLint error')));
      return;
    }
    done();
  });
});
//Watch Task
gulp.task('watch',['compile:css','minify:css','eslint'],function () {
	//Static Server
	browserSync.init({
        server: "./"
    });
	//Watch HTML File Change
	gulp.watch("app/*.html").on('change', browserSync.reload);
	gulp.watch(['./src/sass/**/*.scss'],['compile:Sass']);
	gulp.watch(['./src/css/*.css'],['minify:css']);
	gulp.watch(['./src/js/**/*.js'],['eslint']);
});
gulp.task('default',['connect','watch']);

@@ -438,16 +438,241 @@
 lobby');
+%0A//Static Server%0Agulp.task('serve', function() %7B%0A    browserSync.init(%7B%0A        server: %7B%0A            baseDir: %22./%22%0A        %7D%0A    %7D);%0A    //Watch HTML File Change%0A    gulp.watch(%22*.html%22).on(%22change%22, browserSync.reload);%0A%7D);
 %0A%0A//Sass
@@ -1033,16 +1033,52 @@
 c/css'))
+%0A        .pipe(browserSync.stream())
 ;%0A%7D);%0A%0A/
@@ -1178,20 +1178,16 @@
 .css')%0A%09
-%09%09  
  .pipe(m
@@ -1203,12 +1203,8 @@
 ))%0A%09
-%09%09  
  .pi
@@ -1233,16 +1233,48 @@
 css/'))%0A
+   .pipe(browserSync.stream());%0A
 %09%7D);%0A%0A//
@@ -1402,21 +1402,199 @@
 st(%22
-dist%22));%0A%7D);%0A
+./build/js%22))%0A  .pipe(browserSync.stream());%0A%7D);%0A%0A// create a task that ensures the %60js%60 task is complete before%0A// reloading browsers%0Agulp.task('js-watch', %5B'babel:js'%5D, browserSync.reload);
 %0A%0A%0A/
@@ -2396,209 +2396,67 @@
 ch',
-%5B'compile:css','minify:css','eslint'%5D,function () %7B%0A%09//Static Server%0A%09browserSync.init(%7B%0A        server: %22./%22%0A    %7D);%0A%09//Watch HTML File Change%0A%09gulp.watch(%22app/*.html%22).on('change', browserSync.reload
+function () %7B%0A%09gulp.watch(%5B'./src/sass/**/*.scss'%5D,%5B'sass'%5D
 );%0A%09
@@ -2474,35 +2474,30 @@
 %5B'./src/
-sa
+c
 ss/*
-*/*.s
+.
 css'%5D,%5B'
 compile:
@@ -2492,26 +2492,25 @@
 %5D,%5B'
-compile:Sa
+minify:c
 ss'%5D);%0A
-%09
+  
 gulp
@@ -2528,32 +2528,31 @@
 src/
-css/*.cs
+js/**/*.j
 s'%5D,%5B'
-minify:css
+js-watch
 '%5D);
@@ -2587,18 +2587,16 @@
 .js'%5D,%5B'
-es
 lint'%5D);
@@ -2626,15 +2626,13 @@
 ',%5B'
-connect
+serve
 ','w

fix browserSync