Skip to content

Commit

Permalink
clean up watchify recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Schoffstall committed Dec 12, 2014
1 parent 20774cc commit 6a3b85f
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions docs/recipes/fast-browserify-builds-with-watchify.md
Expand Up @@ -13,24 +13,18 @@ var source = require('vinyl-source-stream');
var watchify = require('watchify');
var browserify = require('browserify');

gulp.task('watch', function() {
var bundler = watchify(browserify('./src/index.js', watchify.args));

// Optionally, you can apply transforms
// and other configuration options on the
// bundler just as you would with browserify
bundler.transform('brfs');

bundler.on('update', rebundle);

function rebundle() {
return bundler.bundle()
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
}

return rebundle();
});
var bundler = watchify(browserify('./src/index.js', watchify.args));
// add any other browserify options or transforms here
bundler.transform('brfs');

gulp.task('js', bundle); // so you can run `gulp js` to build the file
bundler.on('update', bundle); // on any dep update, runs the bundler

function bundle() {
return bundler.bundle()
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./dist'));
}
```

0 comments on commit 6a3b85f

Please sign in to comment.