diff --git a/index.js b/index.js index d04c8e415..bd808b67d 100644 --- a/index.js +++ b/index.js @@ -263,6 +263,13 @@ Browserify.prototype.external = function (file, opts) { Browserify.prototype.exclude = function (file, opts) { if (!opts) opts = {}; + if (isArray(file)) { + var self = this; + file.forEach(function(file) { + self.exclude(file, opts); + }); + return this; + } var basedir = defined(opts.basedir, process.cwd()); this._exclude.push(file); this._exclude.push('/' + relativePath(basedir, file)); @@ -271,6 +278,13 @@ Browserify.prototype.exclude = function (file, opts) { Browserify.prototype.ignore = function (file, opts) { if (!opts) opts = {}; + if (isArray(file)) { + var self = this; + file.forEach(function(file) { + self.ignore(file, opts); + }); + return this; + } var basedir = defined(opts.basedir, process.cwd()); // Handle relative paths diff --git a/readme.markdown b/readme.markdown index 7112d18df..3a051ed3b 100644 --- a/readme.markdown +++ b/readme.markdown @@ -538,12 +538,16 @@ from the current bundle as the bundle in `file` gets bundled. Prevent the module name or file at `file` from showing up in the output bundle. +If `file` is an array, each item in `file` will be ignored. + Instead you will get a file with `module.exports = {}`. ## b.exclude(file) Prevent the module name or file at `file` from showing up in the output bundle. +If `file` is an array, each item in `file` will be excluded. + If your code tries to `require()` that file it will throw unless you've provided another mechanism for loading it.