0

JavaScript libraries like Babel, Nyc, Eslint and many others allows its configurations in resources files or in package.json.

For instance, babel can be configured in .babelrc file or in a babel entry in the package.json file.

What are the advantages / disadvantages of each approach?

Eduardo
  • 657
  • 1
  • 9
  • 28
  • 1
    Possible duplicate of [Whats the difference when configuring webpack babel-loader vs configuring it within package.json?](https://stackoverflow.com/questions/48476373/whats-the-difference-when-configuring-webpack-babel-loader-vs-configuring-it-wit) – AndrewL64 May 17 '18 at 21:22

1 Answers1

1

Pros of .babelrc (or any .*rc file):

  • Separation of concerns in files

  • Easier to find and modify your settings (depending on how stuffed your package.json is)

  • Some people prefer using a runcom file // personal preference

Pros of package.json:

  • Limit file bloat (you could have other .*rc files, test config files, task runner files, readmes, etc.)

  • "Single source of truth" for app configuration

  • Some people prefer using a package.json hack // personal preference

Via - my_ledge_ends

AndrewL64
  • 15,794
  • 8
  • 47
  • 79