Best way to build/compile/deploy ReactJS to production [closed]

心不动则不痛 提交于 2019-11-28 20:53:29
Ian

I recommend using Webpack to bundle your code. It will roll your whole app together into one file (or a few if you get into optimizing webpack a bit more). You can then have a very basic index.html file that that simply loads the bundled js file. Push that to your production server in whatever way you like.

Here is a good tutorial to get you started with Webpack: Setting up React for ES6 with Webpack and Babel (there are a lot of these out there if you don't like this one)

One of the current challenges with React is larger-than-optimal bundle sizes. For complex apps this can start to be a problem for initial page load. Enter isomorphic rendering. React can run server-side and render a snapshot of your app that downloads quickly. Then when your actual app bundle downloads it seamlessly picks up with the current DOM, making for a much snappier user experience when they arrive on your page.

Here is an example for doing isomorphic rendering with React: Example on Github

Go throw "ReactJS isomorphic rendering" in Google for much more info.
Good luck and have fun - this is cool stuff :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!