 
 
 #*------------------------------------*\
+#     $AUTO RELOAD GULPFILE ON SAVE
+#     noxoc.de/2014/06/25/reload-gulpfile-js-on-change/
+#*------------------------------------*/
+gulp.task "auto_reload", () ->
+  process = undefined
+  restart = () ->
+    if process != undefined
+      process.kill()
+    process = spawn 'gulp', ['default'], {stdio: 'inherit'}
+
+  gulp.watch 'gulpfile.coffee', restart
+  restart()
+
+
+
+
+
+#*------------------------------------*\
 #     $UPDATE NPM DEPS
 #*------------------------------------*/
 gulp.task 'update_deps', shell.task 'npm-check-updates -u'
+
+
+
+
+
+#*-------------------------------------*\
+#      $CLEAN
+#*-------------------------------------*/
+gulp.task 'clean:build', (done) ->
+  del "#{conf.path.prod.assets}/**/*", done
+
+
+
+
+
+#*-------------------------------------*\
+#      $BUILD
+#*-------------------------------------*/
+gulp.task 'build', () ->
+  runSequence "clean:build", ["rev:replace", "minify:js:vendors"]
 
 
 



#*------------------------------------*\
#     $AUTO RELOAD GULPFILE ON SAVE
#     noxoc.de/2014/06/25/reload-gulpfile-js-on-change/
#*------------------------------------*/
gulp.task "auto_reload", () ->
  process = undefined
  restart = () ->
    if process != undefined
      process.kill()
    process = spawn 'gulp', ['default'], {stdio: 'inherit'}

  gulp.watch 'gulpfile.coffee', restart
  restart()





#*------------------------------------*\
#     $COFFEE
#*------------------------------------*/
gulp.task "coffee", () ->
  gulp.src ["#{conf.path.dev.coffee}/**/*.coffee"]
    .pipe plumber(conf.plumber)
    .pipe cache(coffee({bare: true}).on('error', gutil.log))
    .pipe remember()
    .pipe gulp.dest(conf.path.dev.js)
    .pipe bs.reload({stream: true})





#*------------------------------------*\
#     $CONCAT
#*------------------------------------*/
gulp.task "concat", ["coffee"], () ->
  gulp.src [
    "#{conf.path.dev.coffee}/lib/toggler.js"
    "#{conf.path.dev.coffee}/main.js"
  ]
    .pipe concat('built.js')
    .pipe gulp.dest(conf.path.dev.js)
    .pipe bs.reload({stream: true})





#*------------------------------------*\
#     $UGLIFY
#*------------------------------------*/
gulp.task "uglify", ["coffee", "concat"], () ->
  files = [
    "#{conf.path.dev.js}/built.js"
  ]

  gulp.src(files)
    .pipe uglifyJs()
    .pipe rev()
    .pipe rename({suffix: '.min'})
    .pipe gulp.dest(conf.path.prod.js)
    .pipe rev.manifest(conf.revManifest.path, conf.revManifest.opts)
    .pipe gulp.dest('./')





#*------------------------------------*\
#     $UGLIFY VENDORS
#*------------------------------------*/
gulp.task "uglify:vendors", () ->
  files = [
    # "**/#{conf.path.dev.assets}/vendor/[your vendor].js",
  ]

  gulp.src files
    .pipe uglifyJs()
    .pipe rename({suffix: '.min'})
    .pipe gulp.dest('./')





#*------------------------------------*\
#     $MINIFY
#*------------------------------------*/
gulp.task "minify", ["sass"], () ->
  gulp.src(["#{conf.path.dev.css}/style.css"])
    .pipe minifyCSS({keepSpecialComments: 0})
    .pipe rev()
    .pipe rename({suffix: '.min'})
    .pipe gulp.dest(conf.path.prod.css)
    .pipe rev.manifest(conf.revManifest.path, conf.revManifest.opts)
    .pipe gulp.dest('./')





#*------------------------------------*\
#     $FONT REV
#*------------------------------------*/
gulp.task "font", () ->
  files = ['eot', 'woff', 'ttf', 'svg'].map (curr) ->
    "#{conf.path.dev.fnt}/**/*.#{curr}"

  gulp.src(files)
    .pipe cache(rev())
    .pipe gulp.dest(conf.path.prod.fnt)
    .pipe rev.manifest(conf.revManifest.path, conf.revManifest.opts)
    .pipe gulp.dest('./')





#*------------------------------------*\
#     $REV REPLACE
#     github.com/jamesknelson/gulp-rev-replace/issues/23
#*------------------------------------*/
gulp.task 'rev_replace', ["uglify", "minify", "font", "imagemin"], () ->
  manifest = require "./#{conf.path.dev.assets}/rev-manifest.json"
  stream = gulp.src ["./#{conf.path.prod.css}/#{manifest['style.css']}"]




#*-------------------------------------*\
#     $BROWSER-SYNC
#*-------------------------------------*/
gulp.task 'browser-sync', () ->
  bs.init {
