webpack-node-externals
Advanced tools
Comparing version 2.1.0 to 2.2.0
{ | ||
"name": "webpack-node-externals", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Easily exclude node_modules in Webpack bundle", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -55,2 +55,5 @@ Webpack node modules externals | ||
#### `options.additionalModuleDirs (='[]')` | ||
Additional folders to look for node modules. | ||
#### `options.modulesFromFile (=false)` | ||
@@ -64,4 +67,4 @@ Read the modules from the `package.json` file instead of the `node_modules` folder. | ||
modulesFromFile: { | ||
exclude: [/* sections to exclude, i.e 'devDependencies' */], | ||
include: [/* sections to explicitly include, i.e only 'dependencies' */] | ||
includeInBundle: [/* whole sections to include in the bundle, i.e 'devDependencies' */], | ||
excludeFromBundle: [/* whole sections to explicitly exclude from the bundle, i.e only 'dependencies' */] | ||
} | ||
@@ -68,0 +71,0 @@ } |
11
utils.js
@@ -40,2 +40,5 @@ var fs = require('fs'); | ||
} | ||
var includeInBundle = options.exclude || options.includeInBundle; | ||
var excludeFromBundle = options.include || options.excludeFromBundle; | ||
// read the file | ||
@@ -52,8 +55,8 @@ var packageJson; | ||
var sections = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']; | ||
if(options.include) { | ||
sections = [].concat(options.include); | ||
if(excludeFromBundle) { | ||
sections = [].concat(excludeFromBundle); | ||
} | ||
if(options.exclude) { | ||
if(includeInBundle) { | ||
sections = sections.filter(function(section){ | ||
return [].concat(options.exclude).indexOf(section) === -1; | ||
return [].concat(includeInBundle).indexOf(section) === -1; | ||
}); | ||
@@ -60,0 +63,0 @@ } |
13119
123
136