4 ms·
Why would you couple Rails + React in the first place? We have a similar project and decided to just put everything React-related into "client" directory in Ra
by tzaman 10y ago
Why would you couple Rails + React in the first place?
We have a similar project and decided to just put everything React-related into "client" directory in Rails, then, once webpack builds production-ready files, it puts them into public/assets (during container build time). And that's it, I can run React without Rails, vice versa, test them independently,... etc.
- pmontra 10y agoYes, I would create two different projects, one Ruby only and one JavaScript only. I wonder if there is a well established pattern for server side rendering of some pages in this kind of applications. Obviously one can use Rails views for some important pages but how not to duplicate HTML in Rails and React?
- tzaman 10y agoHm, why would you need to render some pages in Rails? Why not just go React all the way and use Rails for API only. If you absolutely do need them, I would just separate them by routes.
- pmontra 10y agoIf the SPA is large, server side rendering is faster. Users get the first page in milliseconds, whatever page it is, then the SPA loads and takes over. I would do that for a few entry points to the site, for example the ones that get into the sitemap in the Google results page.
- oelmekki 10y agoAgree with this. While you may feel like you're losing something big by not using the asset pipeline, tools for managing assets in js are now totally awesome. A frontend app using create-react-app has everything to compose js files, load css and even manage sha1 suffixed asset file names.