[英]Server side rendering and codesplitting using create react app and loadable components
Anyone have any experience converting a react app created with create-react-app
to using server side rendering and code splitting via loadable-components
?任何人都有将使用
create-react-app
转换为通过loadable-components
使用服务器端渲染和代码拆分的经验吗? I know this is a general question, but mostly looking for general guidance or any major red flags for this approach.我知道这是一个普遍的问题,但主要是为这种方法寻找一般指导或任何主要的危险信号。 I'd like to keep the nice things you get out of box with
create-react-app
- especially the live reload dev environment - while adding in optimizations using SSR and code splitting.我想保留您使用
create-react-app
开箱即用的好东西——尤其是实时重新加载开发环境——同时使用 SSR 和代码拆分添加优化。 I was able to mostly get this working using express
backend and handlebars
templating, but I'm facing many challenges getting code splitting working correctly with this setup.我能够使用
express
后端和handlebars
模板来完成这项工作,但我面临着许多挑战,让代码拆分在此设置下正常工作。 Any hints / stories are appreciated!任何提示/故事表示赞赏!
There is craco "an easy and comprehensible configuration layer for create-react-app". craco有一个“用于 create-react-app 的简单易懂的配置层”。
Webpack custom configurations go into craco.config.js
, inside root folder. Webpack 自定义配置
craco.config.js
进入根文件夹内的 craco.config.js 。
SSR is possible, you can check two related questions that might help you with your case: SSR 是可能的,您可以检查两个可能对您的案例有帮助的相关问题:
Code splitting loads all chunk files on chrome but load them separately in firefox 代码拆分在 chrome 上加载所有块文件,但在 firefox 中单独加载它们
Loadable Components SSR - chunkNames in Server Stats file different from Client stats file 可加载组件 SSR - 服务器统计文件中的块名称与客户端统计文件不同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.