简体   繁体   English

是否可以避免使用create-react-app捆绑React库?

[英]Is it possible to avoid bundling the React library using create-react-app?

Is it possible to avoid bundling the React library during the build when using create-react-app? 使用create-react-app时是否可以避免在构建过程中捆绑React库? I would rather load it from a CDN. 我宁愿从CDN加载它。 Otherwise, I will have to use WebPack instead, which is alright but I really to use create-react-app as it keeps everything contained and tidy. 否则,我将不得不改用WebPack,这没关系,但是我真的要使用create-react-app,因为它可以使所有内容保持整洁。

Thanks! 谢谢!

There is a very nice tutorial on doing just that here. 这里有一个很好的教程。 The idea is simple, to make clever use of the “ rewire ” module which may swap in your own “customized” build configurations to override those in the “react-scripts” module's default configurations that come with create-react-app. 这个想法很简单,可以巧妙地使用“ rewire ”模块,该模块可以交换您自己的“定制”构建配置,以覆盖create-react-app随附的“ react-scripts”模块默认配置中的配置。

Here's a link to that tutorial . 这是该教程的链接。

Within your “customized” build configs you can easily ignore certain files, by adding their pattern/path to the “exclude” stub. 在“自定义”构建配置中,可以通过将某些文件的模式/路径添加到“排除”存根中轻松地忽略某些文件。 See this for more details. 请参阅了解更多详情。

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

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