Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Commit

Permalink
Improve watchify recipe.
Browse files Browse the repository at this point in the history
As @andreypopp pointed out on IRC, this example was doubling up
on watchers when it only needed to listen to watchify's "update"
event.
  • Loading branch information
hughsk committed Feb 18, 2014
1 parent 32ed800 commit 3b83800
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions docs/recipes/fast-browserify-builds-with-watchify.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ var watchify = require('watchify')
var gulp = require('gulp')

var bundler = watchify('./src/index.js')
var watchFiles = [
'./src/**/*.js',
'./src/*.js'
]

gulp.task('browserify', function() {
gulp.task('browserify', rebundle)
gulp.task('watch', ['browserify'], function() {
bundler.on('update', rebundle)
})

function rebundle() {
return bundler.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'))
})

gulp.task('watch', ['browserify'], function() {
gulp.watch(watchFiles, ['browserify'])
})
}

// Optionally, you can apply transforms
// and other configuration options on the
Expand Down

0 comments on commit 3b83800

Please sign in to comment.