Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持带基座启动 vite + React 子应用吗? #661

Closed
2 tasks done
festina-lente-z opened this issue Feb 22, 2024 · 10 comments
Closed
2 tasks done

支持带基座启动 vite + React 子应用吗? #661

festina-lente-z opened this issue Feb 22, 2024 · 10 comments

Comments

@festina-lente-z
Copy link

festina-lente-z commented Feb 22, 2024

Clear and concise description of the problem

是否支持 vite + React 子应用?目前没有看到 demo。vite子应用只看到 vue 版本的。

复现了一个 demo:https://github.com/festina-lente-z/react-vite-garfish-demo

image
发现子应用引入的代码并没有执行。


更新:我把 @vitejs/plugin-react-swc 插件注释掉,子应用就可以渲染出来了😂
[2024-03-26 更新]:在最小 demo 子应用可以渲染,但是转移到公司项目上还是不行,我参考了这个 #611 直接修改了 node_modules 里面的代码,发现是因为项目代码存在一些间接循环引用问题,修改后便可以渲染出来 🎉~~~~

Suggested solution

支持vite+React子应用

Alternative

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@scris
Copy link

scris commented Mar 18, 2024

我在自己这边的项目中这么用了,是可以成功使用的

@festina-lente-z
Copy link
Author

我在自己这边的项目中这么用了,是可以成功使用的

是带基座启动还是只启动单个vite子应用呀?

@festina-lente-z festina-lente-z changed the title 支持 vite + React 子应用吗? 支持带基座启动 vite + React 子应用吗? Mar 18, 2024
@zhoushaw
Copy link
Member

https://www.garfishjs.org/guide/demo/vite

可以参考这里

@scris
Copy link

scris commented Mar 18, 2024

我在自己这边的项目中这么用了,是可以成功使用的

是带基座启动还是只启动单个vite子应用呀?

主应用、子应用两边都是 vite

@festina-lente-z
Copy link
Author

我在自己这边的项目中这么用了,是可以成功使用的

是带基座启动还是只启动单个vite子应用呀?

主应用、子应用两边都是 vite

请问你的主应用和子应用在一个端口下吗?

@festina-lente-z
Copy link
Author

https://www.garfishjs.org/guide/demo/vite

可以参考这里

image
发现子应用的代码没执行。复现了一个demo:https://github.com/festina-lente-z/react-vite-garfish-demo。

@zhoushaw
Copy link
Member

@festina-lente-z 主子应用不要设置在同一个端口,publicPath 需要补全

@festina-lente-z
Copy link
Author

@festina-lente-z 主子应用不要设置在同一个端口,publicPath 需要补全

想问一下为什么不能在同一个端口,因为目前项目是同一个端口,并且 webpack 那边配置也是可以的

@zhoushaw
Copy link
Member

@festina-lente-z 主子应用不要设置在同一个端口,publicPath 需要补全

想问一下为什么不能在同一个端口,因为目前项目是同一个端口,并且 webpack 那边配置也是可以的

设置在一个端口不会发生冲突吗

@festina-lente-z
Copy link
Author

@festina-lente-z 主子应用不要设置在同一个端口,publicPath 需要补全

想问一下为什么不能在同一个端口,因为目前项目是同一个端口,并且 webpack 那边配置也是可以的

设置在一个端口不会发生冲突吗

我这边试了不会冲突,但是暂时需要注释掉 @vitejs/plugin-react-swc 插件,附件的那个 demo 在同端口可以跑起来

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants