[英]How do I tell Babel CLI to ignore any path with “__” in it?
"@babel/cli": "^7.2.3",
Seems really simple. 看起来真的很简单。
https://babeljs.io/docs/en/babel-cli#ignore-files https://babeljs.io/docs/zh-CN/babel-cli#ignore-files
babel src --out-dir lib --ignore "src/**/*.spec.js","src/**/*.test.js"
So I set it up like so: 因此,我将其设置为:
babel src --out-dir cjs --ignore "**/_*" --copy-file --watch
Glob reference: https://github.com/isaacs/node-glob 全球参考资料: https : //github.com/isaacs/node-glob
But I see this in the output: 但是我在输出中看到了这一点:
add:cjs/__mocks__/@xyz/common-fn.js
add:cjs/middleware/__mocks__/uuid.js
OK I try this: 好吧,我试试这个:
babel src --out-dir cjs --ignore "**/_+","_+" --copy-file --watch
And these: 还有这些:
babel src --out-dir cjs --ignore "**/_*/*.*\ --copy-file --watch
babel src --out-dir cjs --ignore "**/__mocks__/*.*", --copy-file --watch
babel src --out-dir cjs --ignore "[src|middleware]/**/__mocks__/*.*" --copy-file --watch"
babel src --out-dir cjs --ignore "**/_+/**/*.*" --copy-file --watch
Same result every time. 每次相同的结果。 It really seems like that last one should work: ignore any path with zero or more directories followed by a directory that has at least one _ in the name, then zero or more directories then a file matching any pattern. 看起来最后一个应该确实有效:忽略目录中包含零个或多个目录的任何路径,然后忽略名称中至少包含一个_的目录,然后目录零个或多个目录,然后匹配任何模式的文件。 Am I reading that right? 我读对了吗?
Then I tried being very specific: 然后我尝试非常具体:
babel src --out-dir cjs --ignore "nes/middleware/__mocks__/*.js", --copy-file --watch
And I get: 我得到:
add:nes/middleware/__mocks__/localize.js
I can't tell if this is a bug in Babel or me misunderstanding glob patterns. 我不知道这是Babel中的错误还是我误解了glob模式。
There seems to be some debate about whether Babel fully supports Glob patterns at the CLI level. 关于Babel是否在CLI级别上完全支持Glob模式,似乎存在一些争论。
I managed to get it working with this ignore pattern: 我设法使其与这种忽略模式一起使用:
--ignore "src/**/__mocks__/**/*.js" --ignore "src/**/*.test.js"
This pattern **/__*/**
will work in Glob but fails in Babel. 这种模式**/__*/**
在Glob中可以使用,但在Babel中则无法使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.