 
 err = (x...) -> gutil.log(x...); gutil.beep(x...)
 
-webpack = (name, ext, failhard) ->
+webpack = (name, ext, watch) ->
   options =
 #    bail: true
-#    cache: true
-#    watch: true
+    watch: watch
+    cache: true
     devtool: "source-map"
     output:
       filename: "#{name}.js"

  ))
  .on('error', err)
  .pipe(autoprefixer("last 2 versions", "ie 8", "ie 9"))
  .pipe(gulp.dest("#{dist_path}"))

gulp.task 'clean', (callback) ->
  rimraf.sync(dist_path)


gulp.task 'build', ['clean', 'copy', 'css', 'js']

server_main = "#{src_path}/server.coffee"
gulp.task 'server', ->
  nodemon
    script: server_main
    watch: [server_main]
    env:
      PORT: process.env.PORT or 3000

gulp.task 'dev', ['copy', 'css', 'watch', 'server', 'js-dev']

gulp.task 'default', ['dev']

gulp.task 'watch', ->
  livereload.listen()
  gulp.watch("#{dist_path}/**").on('change', livereload.changed)
  # gulp.watch ["#{src_path}/**/*.coffee", "#{src_path}/**/*.cjsx", "#{src_path}/**/*.js"], ['js-dev']
  gulp.watch ["#{src_path}/**/*.less"], ['css']
  gulp.watch ["#{src_path}/**/*.html"], ['copy']
