webpack-node-externals
Advanced tools
Comparing version 1.0.0 to 1.1.0
12
index.js
@@ -15,2 +15,12 @@ var fs = require("fs"); | ||
function containsPattern(arr, val) { | ||
return arr && arr.some(function(pattern){ | ||
if(pattern instanceof RegExp){ | ||
return pattern.test(val); | ||
} else { | ||
return pattern == val; | ||
} | ||
}); | ||
} | ||
module.exports = function nodeExternals(options) { | ||
@@ -34,3 +44,3 @@ options = options || {}; | ||
var pathStart = request.split('/')[0]; | ||
if (contains(nodeModules, pathStart) && !contains(whitelist, request)) { | ||
if (contains(nodeModules, pathStart) && !containsPattern(whitelist, request)) { | ||
// mark this module as external | ||
@@ -37,0 +47,0 @@ // https://webpack.github.io/docs/configuration.html#externals |
{ | ||
"name": "webpack-node-externals", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Easily exclude node_modules in Webpack bundle", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,4 @@ Webpack node modules externals | ||
[![Version](http://img.shields.io/npm/v/webpack-node-externals.svg)](https://www.npmjs.org/package/webpack-node-externals) | ||
[![Version](https://img.shields.io/npm/v/webpack-node-externals.svg)](https://www.npmjs.org/package/webpack-node-externals) | ||
[![Downloads](https://img.shields.io/npm/dm/webpack-node-externals.svg)](https://www.npmjs.org/package/webpack-node-externals) | ||
[![Build Status](https://travis-ci.org/liady/webpack-node-externals.svg?branch=master)](https://travis-ci.org/liady/webpack-node-externals) | ||
@@ -40,3 +41,3 @@ | ||
#### `options.whitelist (=[])` | ||
An array of paths for the `externals` to whitelist, so they **will** be included in the bundle. | ||
An array of paths for the `externals` to whitelist, so they **will** be included in the bundle. Can accept regex patterns. | ||
@@ -57,4 +58,4 @@ #### `options.importType (='commonjs')` | ||
externals: [nodeExternals({ | ||
// this WILL include `jquery` and `webpack/hot/dev-server` in the bundle | ||
whitelist: ['jquery', 'webpack/hot/dev-server'] | ||
// this WILL include `jquery` and `webpack/hot/dev-server` in the bundle, as well as `lodash/*` | ||
whitelist: ['jquery', 'webpack/hot/dev-server', /^lodash/] | ||
})], | ||
@@ -61,0 +62,0 @@ ... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7065
42
89