[英]How to add react-native out-of-tree platforms using Gatsby and create-react-app?
We have a large react-native application and want to extend this application into a website and chrome-extension, the website and chrome extension use the same reducers, sagas and some components (using react-native-web) from our mobile application.我们有一个大型 react-native 应用程序,并希望将此应用程序扩展到网站和 chrome 扩展程序中,该网站和 chrome 扩展程序使用与我们的移动应用程序相同的减速器、saga 和一些组件(使用 react-native-web)。 The chrome extension and website are basically a subset of the mobile app.
chrome 扩展程序和网站基本上是移动应用程序的一个子集。
The idea was to setup the build system to build these platforms in a single repo eg if we run npm run build-chrome-extension
it will build the react extension into a root folder called /extension
, which will live in the same directory as the /ios
and /android
folder, same goes for a /web
folder.我们的想法是设置构建系统以在单个 repo 中构建这些平台,例如,如果我们运行
npm run build-chrome-extension
它会将 react 扩展构建到名为/extension
的根文件夹中,该文件夹将与/ios
和/android
文件夹,同样适用于/web
文件夹。
To achieve this we will use react-native out-of-tree platforms then use file extensions to serve the correct code, CheckoutScreen.website.js
will serve the checkout screen for the website.为了实现这一点,我们将使用react-native out-of-tree 平台,然后使用文件扩展名来提供正确的代码,
CheckoutScreen.website.js
将为网站提供结账屏幕。
The question is, how do we setup the build system to accomplish this?问题是,我们如何设置构建系统来实现这一点? If we want to use Gatsby to build the website, and create-react-app for the chrome-extension.
如果我们想使用 Gatsby 来构建网站,并为 chrome-extension 创建-react-app。
Not sure to answer the question, but you can use https://github.com/slorber/gatsby-plugin-react-native-web不确定回答这个问题,但你可以使用https://github.com/slorber/gatsby-plugin-react-native-web
It uses the Expo-web webpack config (which also works in CRA or Next or homemade webpack), which means your web layer will resolve in priority the .web.js extension.它使用 Expo-webpack 配置(也适用于 CRA 或 Next 或自制的 webpack),这意味着您的 web 层将优先解析 .web.js 扩展名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.