jonkemp/gulp-bundle — pull request #5 by wbyoung (2014-03-01 02:58:07+00:00)
Title: Plugin interface

This is a drastic change that I'm proposing to address #4.

I'd love to discuss it. I think it might be possible to use this idea and merge this together with _gulp-useref_ instead of putting it in here. Either way, I think this could be a good change.

Here's how you can process files with this change now:

```javascript
gulp.task('html', resources, function() {
var bundler = bundle();
var jsFilter = filter('**/*.js');
var cssFilter = filter('**/*.css');
return gulp.src('**/*.html')
.pipe(bundler) // after this we'll only be looking at .js and .css files
.pipe(jsFilter)
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.minifyCss())
.pipe(cssFilter.restore())
.pipe(gulp.dest('dist')) // save out all .js and .css files
.pipe(bundler.restore()) // now we're only working with the html files again
.pipe($.useref())
.pipe(gulp.dest('dist')));
});
```

This feels more true to the ideas of how gulp is supposed to work (each task only does one thing). Actually, this is doing a little more than one thing since it's concatenating files, but I felt that made sense.

We can tweak how this works, but I'd love to know if you're open to making changes like this either in _gulp-bundle_ or _gulp-useref_. I'd prefer not to see the plugin space get any more cluttered up.