gpt4 book ai didi

babeljs - 禁用 .babelrc 继承

转载 作者:行者123 更新时间:2023-12-04 06:17:03 25 4
gpt4 key购买 nike

如何强制 babel 不查看 .babelrc 的父目录?

  • 我有两个 .babelrc文件:./a/.babelrc./a/example/.babelrc .
  • 我在运行 babel./a/example小路。
  • ./a/.babelrc定义了一个插件“lodash”。
  • 我不想在 ./a/example 中执行 babel 时使用这个插件

  • 我试过设置 ./a/example/.babelrc到:
    {
    "stage": 0,
    "plugins": []
    }

    但是,正在运行 babel./a/example路径仍然使用“lodash”插件。
    $ pwd
    /a/example
    $ cat ./.babelrc
    {
    "stage": 0,
    "plugins": []
    }
    $ cat ./../.babelrc
    {
    "stage": 0,
    "plugins": [
    "lodash"
    ]
    }
    $ babel ./src/
    Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
    [..]
    $ babel --babelrc ./.babelrc ./src/
    Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
    [..]

    最佳答案

    有一个未记录的属性叫做 breakConfig .套装breakConfigtrue禁用配置继承。

    这种行为将在 6.x 中改变。在 6.x 中,Babel 将在第一个 .babelrc 处中断它发现。 extends属性将用于显式命名其他 .babelrc要继承的文件。

    关于babeljs - 禁用 .babelrc 继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32540598/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com