Created
July 22, 2020 09:34
-
-
Save kmaraz/d697e98b52a0631709ff71a205ac042f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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