Skip to content
Browse files

fix(watch): do not watch src files that are excluded from dist

  • Loading branch information
jyounce committed Aug 19, 2015
1 parent 4e854ca commit d4ae8e100bd3c6f8484c69edaf6b2d3a5d1a8a8f
Showing with 20 additions and 45 deletions.
  1. +20 −45 tasks/watch/
@@ -22,29 +22,6 @@ module.exports = (gulp, config, browserSync) ->
browserSync: ->
browserSync.reload stream:false

# globs
# =====
getGlob = (loc, type, lang) ->
globs = []
['app'].forEach (v1) ->
['client', 'server'].forEach (v2) ->
for v2 in ['client', 'server']
break if v2 is 'server' and type isnt 'scripts'
_glob = config.glob[loc][v1][v2][type][lang]
continue unless _glob.length
for v3 in _glob
globs.push v3
glob =
coffee: getGlob 'src', 'scripts', 'coffee'
css: getGlob 'src', 'styles', 'css'
es6: getGlob 'src', 'scripts', 'es6'
js: getGlob 'src', 'scripts', 'js'
less: getGlob 'src', 'styles', 'less'
html: getGlob 'src', 'views', 'html'
images: getGlob 'src', 'images', 'all'

# helpers
# =======
getAppOrRb = (file) ->
@@ -127,41 +104,39 @@ module.exports = (gulp, config, browserSync) ->

# html watch (handle angular template cache)
# ==========================================
htmlWatch = ->
createWatch glob.src.html, 'tCache',
lang:'html', srcType:'views', taskOnly:true, logTaskName:'template cache'
createWatch glob.src.html, 'html', lang:'html', srcType:'views', bsReload:true
htmlWatch = (views) ->
return if
createWatch views, 'tCache', lang:'html', srcType:'views', taskOnly:true, logTaskName:'template cache'
createWatch views, 'html', lang:'html', srcType:'views', bsReload:true

# spa watch (if custom spa file then watch it)
# ============================================
spaWatch = ->
return createWatch, 'build spa', lang:
spaWatch = (spaFilePath) ->
return promiseHelp.get() unless
createWatch spaFilePath, 'build spa', lang:

# register task
# =============
gulp.task "#{config.rb.prefix.task}watch", ->
defer = q.defer()
# images
createWatch glob.src.images, 'image', lang:'image', srcType:'images', bsReload:true
createWatch, 'image', lang:'image', srcType:'images', bsReload:true
# styles
createWatch glob.src.css, 'css', lang:'css', srcType:'styles'
createWatch glob.src.less, 'less', lang:'less', srcType:'styles', extDist:'css'
# scripts
createWatch[0], 'coffee', lang:'coffee', srcType:'scripts', extDist:'js'
createWatch[1], 'coffee', lang:'coffee', srcType:'scripts', extDist:'js', loc:'server'
createWatch glob.src.es6[0], 'es6', lang:'es6', srcType:'scripts', extDist:'js'
createWatch glob.src.es6[1], 'es6', lang:'es6', srcType:'scripts', extDist:'js', loc:'server'
createWatch glob.src.js[0], 'js', lang:'js', srcType:'scripts'
createWatch glob.src.js[1], 'js', lang:'js', srcType:'scripts', loc:'server'
createWatch, 'css', lang:'css', srcType:'styles'
createWatch, 'less', lang:'less', srcType:'styles', extDist:'css'
# client scripts
createWatch, 'coffee', lang:'coffee', srcType:'scripts', extDist:'js'
createWatch, 'es6', lang:'es6', srcType:'scripts', extDist:'js'
createWatch, 'js', lang:'js', srcType:'scripts'
# server scripts
createWatch, 'coffee', lang:'coffee', srcType:'scripts', extDist:'js', loc:'server'
createWatch, 'es6', lang:'es6', srcType:'scripts', extDist:'js', loc:'server'
createWatch, 'js', lang:'js', srcType:'scripts', loc:'server'
# views
# spa
]).done -> defer.resolve()

0 comments on commit d4ae8e1

Please sign in to comment.
You can’t perform that action at this time.