 SERVER_FILE = './server/server.coffee'
 SERVER_PATH = ['./server/**/*.coffee']
 BUILD_PATH  = argv.outputDir ? './static/a/out'
+devMode     = argv.devMode?
 
 log = (color, message) -> gutil.log gutil.colors[color] message
 
 watchLogger = (color, watcher) ->
-  server = livereload()
+  server = livereload()  if devMode
   watcher.on 'change', (event) ->
     log color, "file #{event.path} was #{event.type}"
     server?.changed event.path
 
 gulpBrowserify = (options = {}) ->
   options.extensions or= ['.coffee']
-  options.debug       ?= yes
+  options.debug        = devMode
   b = browserify options
   b.transform coffeeify
   b.bundle()


gulp.task 'sprites@1x', ->

  spriteStream = gulp.src 'static/sprites@1x/**/*.png'
    .pipe spritesmith
      imgName   : 'sprite@1x.png'
      cssName   : 'sprite@1x.styl'

  gulpBrowserify
      entries : ['./app/coffee/main.coffee']
    .pipe source 'main.js'
    .pipe gulpBuffer()
    .pipe pistachio()
    .pipe gulpStream()
    .pipe gulpif devMode, livereload()
    .pipe gulp.dest "#{BUILD_PATH}/js"


gulp.task 'watch-coffee', -> watchLogger 'cyan', gulp.watch COFFEE_PATH, ['coffee']

