以下内容是否exclude: '/node_modules/'仅排除同一目录中的node_modules文件夹,还是会排除嵌套的node_module文件夹?如果不是:我如何调整它以排除所有node_module文件夹?
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader',exclude: '/node_modules/' }
]
},
Run Code Online (Sandbox Code Playgroud)
Filestructure:
/general
/node_modules
/mod1
/src
/node_modules
/mod2
/src
/node_modules
Run Code Online (Sandbox Code Playgroud)
Juh*_*nen 12
文档说明了这一点
条件可以是RegExp,包含绝对路径的字符串,函数(absPath):bool,或其中一个与"和"组合的数组.
因此,基于此,您可以尝试构建一个适合您案例的RegExp.
我个人更喜欢使用include,exclude因为白名单比黑名单更容易维护.至少你有这种方式更强的控制力.
按照这种思路,您可以exclude完全跳过问题并构建如下规则:
include: [
path.resolve(__dirname, 'general'),
path.resolve(__dirname, 'mod1/src'),
path.resolve(__dirname, 'mod2/src')
]
Run Code Online (Sandbox Code Playgroud)
当然,如果你有更复杂的结构,你最终可能会两者兼而有之.一个规则exclude node_modules和一个规则include,你要考虑的目录.
| 归档时间: |
|
| 查看次数: |
9839 次 |
| 最近记录: |