webpack-node-externals
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -37,2 +37,4 @@ var fs = require("fs"); | ||
return pattern.test(val); | ||
} else if (typeof pattern === 'function') { | ||
return pattern(val); | ||
} else { | ||
@@ -39,0 +41,0 @@ return pattern == val; |
{ | ||
"name": "webpack-node-externals", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Easily exclude node_modules in Webpack bundle", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -40,3 +40,3 @@ Webpack node modules externals | ||
#### `options.whitelist (=[])` | ||
An array of paths for the `externals` to whitelist, so they **will** be included in the bundle. Can accept exact strings (`'module_name'`) or regex patterns (`/^module_name/`). | ||
An array for the `externals` to whitelist, so they **will** be included in the bundle. Can accept exact strings (`'module_name'`), regex patterns (`/^module_name/`), or a function that accepts the module name and returns whether it should be included. | ||
<br/>**Important** - if you have set aliases in your webpack config with the exact same names as modules in *node_modules*, you need to whitelist them so Webpack will know they should be bundled. | ||
@@ -85,2 +85,14 @@ | ||
#### How can I bundle required assets (i.e css files) from node_modules? | ||
Using the `whitelist` option, this is possible. We can simply tell Webpack to bundle all files with extensions that are not js/jsx/json, using this [regex](https://regexper.com/#%5C.(%3F!(%3F%3Ajs%7Cjson)%24).%7B1%2C5%7D%24): | ||
```js | ||
... | ||
nodeExternals({ | ||
// load non-javascript files with extensions, presumably via loaders | ||
whitelist: [/\.(?!(?:jsx?|json)$).{1,5}$/i], | ||
}), | ||
... | ||
``` | ||
Thanks @wmertens for this idea. | ||
## Contribute | ||
@@ -87,0 +99,0 @@ Contributions and pull requests are welcome. Please run the tests to make sure nothing breaks. |
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
9100
69
105