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

Egg + React 多页面服务端渲染方案引入react loadable报错 #44

Closed
HadeAs opened this issue Nov 15, 2019 · 11 comments
Closed

Egg + React 多页面服务端渲染方案引入react loadable报错 #44

HadeAs opened this issue Nov 15, 2019 · 11 comments
Labels

Comments

@HadeAs
Copy link

HadeAs commented Nov 15, 2019

20191115155256

项目地址

复现步骤:

  • 代码下载
  • yarn
  • yarn dev

问题代码在app/web/page/home/home.jsx

请问是我哪里写错了,还是有bug

@HadeAs
Copy link
Author

HadeAs commented Nov 15, 2019

貌似require引入的图片资源也加载不了

@HadeAs
Copy link
Author

HadeAs commented Nov 15, 2019

@hubcarl 麻烦看一下

@hubcarl
Copy link
Collaborator

hubcarl commented Nov 19, 2019

@HadeAs 好,今天看一下

@hubcarl
Copy link
Collaborator

hubcarl commented Nov 19, 2019

@HadeAs 初步定位了一下,这个与 webpack entry路径有关系,entry没有路径就可以;目前Demo生成的entry是home/home.js,改成 home.js 就可以,具体看一下master.根本解决办法需要再看看

@HadeAs
Copy link
Author

HadeAs commented Nov 19, 2019

这种方法我也试了,但是这种配置方式如果在entry里加上loader,启动就会报错
20191119132751

20191119133207

@hubcarl 麻烦再看一下

@hubcarl
Copy link
Collaborator

hubcarl commented Nov 19, 2019

临时解决办法:可以不用 loader 方式,loader 改成 app.js 方式, 入口文件改成 js, 类似下面这种,自己实现入口

https://github.com/easy-team/egg-react-webpack-boilerplate/blob/master/app/web/framework/app.js

@hubcarl
Copy link
Collaborator

hubcarl commented Nov 19, 2019

@HadeAs 或者通过customize方法把webapck entry的key统一处理一下,比如把/换成_

//${root}/webpack.config.js
module.exports = {
  ...
  customize(webpackConfig){ // 此外 webpackConfig 为原生生成的 webpack config
   return webpackConfig;
  }
}

找不到模块问题的方案还在验证测试

@HadeAs
Copy link
Author

HadeAs commented Nov 20, 2019

@HadeAs 或者通过customize方法把webapck entry的key统一处理一下,比如把/换成_

//${root}/webpack.config.js
module.exports = {
  ...
  customize(webpackConfig){ // 此外 webpackConfig 为原生生成的 webpack config
   return webpackConfig;
  }
}

找不到模块问题的方案还在验证测试

好的 感谢解答

hubcarl pushed a commit to easy-team/easywebpack-react that referenced this issue Nov 20, 2019
@hubcarl
Copy link
Collaborator

hubcarl commented Nov 20, 2019

@HadeAs 发布了 @easy-team/[email protected] 可以验证一下, master 增加例子

@HadeAs
Copy link
Author

HadeAs commented Nov 21, 2019

@HadeAs 发布了 @easy-team/[email protected] 可以验证一下, master 增加例子

好的 我试一下

@hubcarl hubcarl pinned this issue Dec 12, 2019
@hubcarl hubcarl closed this as completed Dec 12, 2019
@lpg-kobe
Copy link

lpg-kobe commented May 7, 2020

@HadeAs 麻煩幫忙看看rax分支的page/async.jsx也是由於引用了loadable之後該頁面同樣出現報錯的情況,頁面再次刷新本地進程會被強退

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

No branches or pull requests

3 participants