简体   繁体   English

找不到.babel和react-hot-loader的正确配置

[英]Can't find the proper configuration for .babel and react-hot-loader

I'm using babel 7. 我正在使用Babel 7。

In their docs they mention the new naming for plugin is with @babel/ prefix. 他们在他们的文档中提到插件的新命名是@babel/前缀。

React-hot-loader babrlrc config recommendation is: react-hot-loader babrlrc配置建议为:

{
  "plugins": ["react-hot-loader/babel"]
}

my .babelrc config is: 我的.babelrc配置为:

{
  "presets": ["@babel/env", "@babel/react"],
  "env": {
    "development": {
      "plugins": ["@babel/react-hot-loader"]
    },
    "production": {}
  }
}

Is it correct to assume that @babel/react-hot-loader is correct definision? 假设@babel/react-hot-loader是正确的定义是否正确?

I could not find any more docs about it. 我找不到关于它的更多文档。

Saying @babel/react-hot-loader will have babel look within itself for a plugin called react-hot-loader . @babel/react-hot-loader将使babel在其内部寻找名为react-hot-loader的插件。 From what I can tell the package/plugin you're trying to use is not maintained/owned by babel itself. 据我所知,您要使用的软件包/插件不是babel自己维护/拥有的。 Therefore @babel/react-hot-loader will not work. 因此, @babel/react-hot-loader无法正常工作。 You should configure your .babelrc as per the documentation of the plugin you're trying to use. 您应该按照要使用的插件文档配置.babelrc

I think this is the plugin you're referring to in your question: react-hot-loader 我认为这是您在问题中所指的插件: react-hot-loader

Follow these setup instructions: react-hot-loader/getting-started 请遵循以下设置说明: react-hot-loader / getting-started

you have to still use it as mentioned in react hot reloader docs. 您仍然必须按照React Hot Reloader文档中所述使用它。 below is the link 以下是链接

https://github.com/gaearon/react-hot-loader#user-content-add-babel-before-typescript https://github.com/gaearon/react-hot-loader#user-content-add-babel-before-typescript

I don't think so, react-hot-loader does not update there docs for prefix definition and I also found there given example https://github.com/gaearon/react-hot-loader/blob/master/examples/typescript/.babelrc 我不这么认为,react-hot-loader不会更新那里的前缀定义文档,而且我也找到了给定示例的https://github.com/gaearon/react-hot-loader/blob/master/examples/typescript /.babelrc

Using babel 7 prefix for other plugins but for react-hot-loader still the same 将babel 7前缀用于其他插件,但对于react-hot-loader仍然相同

{ "plugins": [ "@babel/plugin-syntax-typescript", "@babel/plugin-syntax-decorators", "@babel/plugin-syntax-jsx", "react-hot-loader/babel" ] }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM