Add ability to pass through transform plugins to browserify.
This commit is contained in:
parent
2d063f1fe4
commit
1622715a51
@ -2,7 +2,12 @@
|
||||
import plugins = require("./gulpbrowser.plugins");
|
||||
|
||||
|
||||
let browserify = function() {
|
||||
let browserify = function(transforms) {
|
||||
|
||||
transforms = transforms || [];
|
||||
if (typeof transforms === 'function') {
|
||||
transforms = [transforms];
|
||||
}
|
||||
|
||||
let forEach = function(file, enc, cb){ // do this with every chunk (file in gulp terms)
|
||||
|
||||
@ -18,8 +23,17 @@ let browserify = function() {
|
||||
};
|
||||
|
||||
if(file.contents.length > 0){
|
||||
plugins.browserify(file, { basedir: file.base })
|
||||
.bundle(bundleCallback);
|
||||
let browserified = plugins.browserify(file, { basedir: file.base });
|
||||
|
||||
transforms.forEach(function (transform) {
|
||||
if (typeof transform === 'function') {
|
||||
browserified.transform(transform);
|
||||
} else {
|
||||
browserified.transform(transform.transform, transform.options);
|
||||
}
|
||||
});
|
||||
|
||||
browserified.bundle(bundleCallback);
|
||||
} else {
|
||||
plugins.beautylog.warn("gulp-browser: .browserify() file.contents appears to be empty");
|
||||
cb(null,file);
|
||||
|
Loading…
Reference in New Issue
Block a user