swisscom / reactintegration
此包最新版本(2.0.0)没有提供许可证信息。
2.0.0
2022-01-24 12:34 UTC
Requires
- neos/flow: ^6.0 || ^7.0
README
create-react-app (CRA) 特别针对单页应用进行了优化;但通过一些变通方法,也可以用于开发多页应用中的JS。此包包含了这些变通方法。
CRA的主要问题是默认没有运行dev-server watch模式的途径,并使其输出静态JS文件,我们可以简单地包含它们。这可能在这个PR合并到CRA中得到解决。
此外,CRA使用了代码拆分;因此在开发过程中,dev服务器的URL非常频繁地改变。
功能
此包提供了一个 Swisscom.ReactIntegration:ReactScripts
融合原型,该原型渲染必要的 script
标签。在开发模式下,它从CRA dev-server(通过CURL到 https://:3000)提取脚本标签URL;在生产模式下,它简单地输出构建的文件。
示例
page.body.javascripts.reactScripts = Swisscom.ReactIntegration:ReactScripts {
# path to the JavaScript *folder* of the built react app. Required.
path = 'resource://Your.Package/Public/BuiltReactApp/js'
# optional: path to the dev server
developmentServerUrl = 'http://other-ip-here:3000'
}
如果设置 Swisscom.ReactIntegration.productionMode
为 true(默认在 Production
上下文中),我们加载构建的JS。否则,我们加载CRA dev服务器URL中的脚本。
安装
-
按常规安装此包。
-
使用 create-react-app 在
[YourPackage]/Resources/Private/react-app
中启动您的react应用。 -
从
[YourPackage]/Resources/Public/BuiltReactApp
到[YourPackage]/Private/JavaScript/build/static
添加一个符号链接;例如,通过输入ln -s ../Private/JavaScript/build/static BuiltReactApp
来完成。 -
将以下融合添加到您的页面中
page.body.javascripts.reactScripts = Swisscom.ReactIntegration:ReactScripts { # path to the JavaScript *folder* of the built react app. Required. path = 'resource://YourPackage/Public/BuiltReactApp/js' }