javascript Eject 在 Create React App 中做了什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49737652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What Does Eject do in Create React App?
提问by foreyez
I think it has something to do with using webpack directly and therefore gives more flexibility. But I'm not completely sure if someone can explain what "ejecting" means. Also what are the ramifications of ejecting a create react app? Is it bad to do this, or?
我认为这与直接使用 webpack 有关,因此提供了更大的灵活性。但我不完全确定是否有人可以解释“弹出”的含义。弹出 create react 应用程序的后果是什么?这样做是不好的,还是?
回答by Tomasz Mularczyk
To bootstrap a reactproject it will require for you to know about things like Webpackor Babelwhich might be a sticking point for people who do not want to learn about these.
要引导一个react项目,你需要了解Webpack或Babel 之类的东西,这对于不想学习这些东西的人来说可能是一个症结。
create-react-appprovides a fully configured environment with reasonable defaults (and possible to extend). Most infrastructure-related work is hidden from you, and whenever there are changes in one of the dependent packages this is taken care of for you -- it will only be required to update react-scripts.
create-react-app提供具有合理默认值(并且可以扩展)的完全配置的环境。大多数与基础设施相关的工作对您来说都是隐藏的,每当依赖包之一发生变化时,这都会为您处理——只需要更新react-scripts.
I highly recommend this presentation by one of CRA authorsit will give you a better idea of the project.
我强烈推荐CRA 作者之一的这个演讲,它会让你更好地了解这个项目。
Now ejectmeans that all of the configuration will be exposed to you. You will see every package which runs your project. Now you are responsible for maintaining all of that configuration.
现在弹出意味着所有配置都将向您公开。您将看到运行您的项目的每个包。现在您负责维护所有这些配置。
This is not necessarily a bad thing; you are then left with more code to maintain, but you get full control in return.
这不一定是坏事;然后,您需要维护更多代码,但作为回报,您可以获得完全控制权。

