DEV Community

Soumya Mishra
Soumya Mishra

Posted on

Use Case for Babel Configuration Files

One cannot imagine working on a Javascript project without babel. Whether it's NodeJs or browsers, you need babel.

Babel provides 2 ways for the configuration:

  1. babel.config.json (there are multiple supported extension)
  2. babelrc.json (there are multiple supported extension)

Now, the point comes which of the above files to be used as per your use case.

  1. babel.config.json

This has been included with the babelv7.x to resolve multiple project-wide Issues. This configuration file comes into the picture when you just want to have a single configuration for the whole project. If you are using a mono-repo or you want to compile your node_modules.

This file is created at the root of your project, where package.json resides. This configuration file applies broadly to the project and even applies plugins and presets to the node modules folder.

  1. babelrc.json

You have a configuration that only applies to a single part of your project. It allows you to create independent configurations for subsections of a package.

Also, both the config files can be used together in a case where you want to have a project-wide configuration, but also need some independent configurations.

For example, a mono-repo can have a project-wide configuration, but each of its packages can be build using a babelrc.json file.

Hope, that my learnings will help someone.

Happy Learning!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay