禁用 .babelrc 继承
Disable .babelrc inheritance
如何强制 babel 不查看 .babelrc
的父目录?
- 我有两个
.babelrc
文件:./a/.babelrc
和 ./a/example/.babelrc
。
- 我在
./a/example
路径中 运行 babel
。
./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
文件。
如何强制 babel 不查看 .babelrc
的父目录?
- 我有两个
.babelrc
文件:./a/.babelrc
和./a/example/.babelrc
。 - 我在
./a/example
路径中 运行babel
。 ./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
文件。