Find file
90 lines (65 sloc) 1.83 KB
layout title description permalink
How to use the .babelrc

All Babel API options except the callbacks are allowed (because .babelrc files are serialized as JSON5).


  "plugins": ["transform-react-jsx"],
  "ignore": [

Use via package.json

You can alternatively choose to specify your .babelrc config from within package.json like so:

  "name": "my-package",
  "version": "1.0.0",
  "babel": {
    // my babel config here

env option

You can use the env option to set specific options when in a certain environment:

  "env": {
    "production": {
      "plugins": ["transform-react-constant-elements"]

Options specific to a certain environment are merged into and overwrite non-env specific options.

The env key will be taken from process.env.BABEL_ENV, when this is not available then it uses process.env.NODE_ENV if even that is not available then it defaults to "development".

You can set this environment variable with the following:


At the start of a command:


Or as a separate command:

export NODE_ENV=production


SET BABEL_ENV=production

Lookup behavior

Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel up the directory tree until it finds either a .babelrc, or a package.json with a "babel": {} hash within.

Use "babelrc": false in options to stop lookup behavior, or provide the --no-babelrc CLI flag.