如何强制 babel 不查看 .babelrc
的父目录?
.babelrc
文件:./a/.babelrc
和 ./a/example/.babelrc
. babel
在 ./a/example
小路。 ./a/.babelrc
定义了一个插件“lodash”。./a/example
中执行 babel 时使用这个插件我试过设置
./a/example/.babelrc
到:{
"stage": 0,
"plugins": []
}
但是,正在运行
babel
在 ./a/example
路径仍然使用“lodash”插件。$ pwd
/a/example
$ cat ./.babelrc
{
"stage": 0,
"plugins": []
}
$ cat ./../.babelrc
{
"stage": 0,
"plugins": [
"lodash"
]
}
$ babel ./src/
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
[..]
$ babel --babelrc ./.babelrc ./src/
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
[..]
最佳答案
有一个未记录的属性叫做 breakConfig
.套装breakConfig
至 true
禁用配置继承。
这种行为将在 6.x 中改变。在 6.x 中,Babel 将在第一个 .babelrc
处中断它发现。 extends
属性将用于显式命名其他 .babelrc
要继承的文件。
关于babeljs - 禁用 .babelrc 继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32540598/