Where is the .babelrc file located?

I installed Babel and found out that you need to modify the .babelrc file to compile JSX? Where is the file located? I searched in the folders Babel-Preset, Babel, Babel-JSX and so on, but could not find it? Should it be created manually?

+6
source share
3 answers

The .babelrc file is your local configuration of your code in your project. Typically, you put it at the root of your application repository. This will affect all files that Babel processes that are in the same directory or in the directories of the .babelrc sister.

+6
source

.babelrc could potentially exist in several places in the node tree.

The root folder of the project will be most likely. The babel configuration can also be specified in package.json under "babel:" {...}

Search behavior

Babel will look for .babelrc in the current directory of the transferred file. If it does not exist, it will move through the directory tree until it finds either .babelrc or package.json with "babel": {} hash inside.

Use "babelrc": false to stop the search behavior.

See https://github.com/insin/babel-plugin-react-html-attrs/blob/master/README.md and Look Up behavior -

+2
source

.babelrc is never created automatically. You must go to the root directory of your project. Create a file - tap .babelrc, open the file and enter the Babel settings here, and then save. If you follow https://babeljs.io/blog/2015/10/31/setting-up-babel-6 , configure Babel 6 and install all the plugins and presets as indicated, this may help.

 { "presets": [ "es2015", "env", "react", "stage-2" ] }, { "plugins": [ "transform-es2015-arrow-functions", "check-es2015-constants", "transform-es2015-block-scoping" ] } 
+2
source

All Articles