Will the following exclude: '/node_modules/'
only exclude the node_modules folder in the same directory, or will it also exclude the nested node_module folders? If not: how can I adjust it to exclude all the node_module folders?
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader',exclude: '/node_modules/' }
]
},
Filestructure:
/general
/node_modules
/mod1
/src
/node_modules
/mod2
/src
/node_modules
The documentation says that
A condition may be a RegExp, a string containing the absolute path, a function(absPath): bool, or an array of one of these combined with “and”.
So based on that you could try to build a RegExp to fit your case.
Personally I prefer to use include
over exclude
as a whitelist is easier to maintain than a blacklist. At least you have stronger control this way.
Following this line of thought you could skip exclude
problem altogether and build a rule like this:
include: [
path.resolve(__dirname, 'general'),
path.resolve(__dirname, 'mod1/src'),
path.resolve(__dirname, 'mod2/src')
]
Of course if you have more complicated structure maybe you'll end up doing a combination of both. One rule to exclude
node_modules and one rule to include
the directories you want to look into.
If your issue is only with TypeScript files, you can take advantage of the fact that 'ts-loader'
will use your tsconfig.json
file upon compiling. You can define paths you want to exclude right there instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With