Skip to content

Commit

Permalink
Array support for b.exclude() and b.ignore()
Browse files Browse the repository at this point in the history
  • Loading branch information
bakape authored and goto-bus-stop committed Oct 21, 2017
1 parent 8dfecd5 commit cc938e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions index.js
Expand Up @@ -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));
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions readme.markdown
Expand Up @@ -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.

Expand Down

0 comments on commit cc938e1

Please sign in to comment.