Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Created July 22, 2020 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaraz/d697e98b52a0631709ff71a205ac042f to your computer and use it in GitHub Desktop.
Save kmaraz/d697e98b52a0631709ff71a205ac042f to your computer and use it in GitHub Desktop.
const excludeNodeModulesExcept = function (modules) {
var pathSep = path.sep;
if (pathSep == '\\')
// must be quoted for use in a regexp:
pathSep = '\\\\';
var moduleRegExps = modules.map(function (modName) {
return new RegExp('node_modules' + pathSep + modName);
});
return function (modulePath) {
if (/node_modules/.test(modulePath)) {
for (var i = 0; i < moduleRegExps.length; i++)
if (moduleRegExps[i].test(modulePath)) return false;
return true;
}
return false;
};
};
// Later in the file
...
rules: [
{
test: /\.js$/,
use: [babelLoader],
exclude: excludeNodeModulesExcept(['debug', '@angular']), // <<<<< THIS PART IS NEEDED
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment