How do I force babel NOT to look at the parent directory for .babelrc
?
.babelrc
files: ./a/.babelrc
and ./a/example/.babelrc
.babel
in ./a/example
path../a/.babelrc
defines a plugin “lodash"../a/example
I have tried setting ./a/example/.babelrc
to:
{
"stage": 0,
"plugins": []
}
However, running babel
in ./a/example
path still uses "lodash" plugin.
$ 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'
[..]
babelrc would be useful if you want to run certain transformations / plugins on a subset of files /directories. Maybe you have 3rd party libraries that you don't want to be transformed/changed by babel.
The . babelrc file is your local configuration for your code in your project. Generally you would put it in the root of your application repo. It will affect all files that Babel processes that are in the same directory or in sibling directories of the . babelrc .
There is an undocumented property called breakConfig
. Set breakConfig
to true
to disable config inheritance.
This behaviour is going to change in 6.x. In 6.x Babel will break on the first .babelrc
it finds. extends
property is going to be used to explicitly name other .babelrc
files to inherit from.
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