简体   繁体   English

我可以在一个项目中有2个babelrc文件吗?

[英]Can I have 2 babelrc files in one project?

I'm trying to add react to a very large solution, but one component on the site uses preact. 我正在尝试添加对一个非常大的解决方案的反应,但网站上的一个组件使用preact。 My current .bablerc is 我目前的.bablerc是

{
  "presets": ["env"],
  "ignore": [
      "**/what-input.js",
      "**/HostedPCIAdapter.js",
      "InstantPreview/**/*.js",
      "Wishlist/**/*.js"
    ],
  "plugins": [
    "transform-object-rest-spread",
    "transform-react-jsx"
  ]
}

Original .baberc looked like this: 原来.baberc看起来像这样:

{
"sourceMaps": true,
"presets": [],
"plugins": [
[
    "transform-react-jsx",
{
    "pragma": "preact.h"
} 
],
"transform-object-assign",
[
    "transform-es2015-classes",
    {
        "loose": true 
    }
],
"transform-es2015-arrow-functions",
"transform-es2015-block-scoping",
"transform-es2015-template-literals"
]

}

So can I add pragma back for just the wishlist feature? 那么我可以为愿望清单功能添加pragma吗? Any help would be appreciated. 任何帮助,将不胜感激。 I'm using gulp as a taskrunner and webpack to build my assets. 我正在使用gulp作为taskrunner和webpack来构建我的资产。

Babel files can be nested in sub-directories with unique settings which is pretty cool stuff. Babel文件可以嵌套在具有独特设置的子目录中,这非常酷。

So if you have a folder structure like this: 所以如果你有这样的文件夹结构:

app
    reactCode
        .babelrc
        index.js
    preactCode
        .babelrc
        index.js

You can add a separate .babelrc file for branch. 您可以为分支添加单独的.babelrc文件。 I don't think it's ideal but if you're working with a large monolithic solution that has lots of different frameworks and requirements it certainly can fix a lot of bugs and QA work. 我认为这不是理想的,但如果您正在使用具有许多不同框架和要求的大型单片解决方案,它肯定可以解决许多错误和QA工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的项目中是否可以有多个gruntjs文件用于代码组织? - Can I have multiple gruntjs files in my project for code organization? 你可以在 .babelrc 中使用正则表达式吗? - Can you use a regex in .babelrc? 如何通过移动 JavaScript 项目中的文件进行重构并自动更新引用? - How can I refactor by moving files in a JavaScript project and have references update automatically? 如何拥有多个控制器文件? - How can I have multiple controller files? 我可以有多个Grunt文件吗 - Can I have multiple Grunt files 一个连接上可以有多个“类别”吗? - Can I have multiple “categories” on one connection? 我有2个复选框,只能单击一个 - I have 2 checkboxes and only one can be clicked 我可以在html的一个脚本中拥有2个功能吗? - Can i have 2 function in one script in html? 如何在一种形式(一个按钮)中进行2个动作? - How can I have 2 actions within one form, one button? 如何做到这一点我希望如果用户单击标记的图像而不是卷轴开始在其他页面上播放我在一个项目中有一个项目 - How to do this I want that if a user click on the marked image than reels start playing on other page i have one project in one project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM