How to extend a parent babel config?

Paul Razvan Berg

With eslint, I can do this:

.eslintrc.js
packages/
  foo/
    .eslintrc.js
  bar/
    .eslintrc.js

Where the child .eslintrc.js looks like this:

{
  "extends": ["react-app", "../../.eslintrc.js"]
}

Can I do this with babel configuration files? I know about --root-mode=upward, but I don't think that helps here.

Paul Razvan Berg

I figured it out thanks to this article: So What's New in Babel 7.

Since v7, you can add overrides to your configuration file:

//babel.config.js
module.exports = {
  presets: [ ... ],
    overrides: [
    {
      test: ["./packages/bar"],
      presets: ["@babel/preset-react"],
    },
  ],
}

Where:

  • test = the glob pattern to match a certain path in your repository
  • presets = the presets you want to add to your selective configuration (note that the default presets are preserved)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to get data from parent class (not extend)

分類Dev

How to extend default webpack config in Ionic v2

分類Dev

How to extend default webpack config in Ionic v2

分類Dev

How do I directly extend an SCSS parent selector?

分類Dev

Docker - extend the parent's ENTRYPOINT

分類Dev

How to extend a React component?

分類Dev

How to extend a React component?

分類Dev

How to extend a React component?

分類Dev

How to extend BitBake class

分類Dev

Where to find polyfill names to add to babel.config.js

分類Dev

Webpackのbabel-loaderにはbabel.config.jsが必要ですか?

分類Dev

correct way to extend __init__ in python 3 from parent class

分類Dev

Extend pixi.js sprite an accessing parent's properties in constructor

分類Dev

How to install Babel in Windows OS?

分類Dev

How to extend my root (/) partition?

分類Dev

How to extend ElementFinder object in ProtractorJS?

分類Dev

How to extend a Generic Collection in Delphi?

分類Dev

Android Kotlin - How to extend ConstraintLayout?

分類Dev

Javascript composition how to extend an object

分類Dev

How to extend html file in Django

分類Dev

How to set resolve for babel-loader presets

分類Dev

How to extend the ls command by a custom column

分類Dev

How to Correctly Extend LinearLayout to Create a Custom View

分類Dev

How to extend `==` behavior to vectors that include NAs?

分類Dev

How to extend validation form request in Laravel 5.2?

分類Dev

How to extend a module by extending a class that it is using?

分類Dev

How to extend a union type with an additional property?

分類Dev

How to extend the java HashSet class with a new function?

分類Dev

How to create and extend a abstract class component in VueJS?

Related 関連記事

ホットタグ

アーカイブ