News for hackers. Stuff that matters.
Re:Modern Front-end in Rails by pmontra on Friday December 08, 2017 @03:00PM (#15881517)
It's probably a matter of tastes, either one project or two projects.

I've been working with Rails since 2006 and I'll create two separate projects. A Rails API project and a front end one. Two projects, two repositories, maybe two teams (specialized teams are more common than full stack.) The front end is served by the reverse proxy in front of Rails.

If I want to serve some semi-static HTML page from Rails, all I have to do is sharing the CSS file and create a controller for that (PagesController is a classic.) I don't think there are many chances of sharing HTML in a meaningful way among ERB and JSX, that must be duplicated.

Then Rails people will work with Rails tools and JavaScript people will work with the favorite tools of the month. The advantage is that if you want to onboard some pure front end developers they won't have to learn about Rails.

Re:Modern Front-end in Rails by demiazz on Friday December 08, 2017 @05:22PM (#15882596)
Of course! If you have human resource to separate and maintain backend and frontend - it's an excellent solution.

But it's article not for teams like this. The described solution for full-stack developers and small projects, which needs to be maintainable too. And component manner is a proper way to organize frontend code.

Re:Modern Front-end in Rails by pmontra on Friday December 08, 2017 @05:43PM (#15882759)
I would split in two even if I'm working on it alone.
Re:Modern Front-end in Rails by demiazz on Friday December 08, 2017 @06:08PM (#15882909)
Ok. Let's see from another side on this point.

If you are beginner Rails developer who doesn't know how to configure Webpack properly and doesn't know how to works with React/Vue/Ember?

And if your project must be a SEO-friendly? You don't know React, Webpack and doesn't know how to works with React/Vue SSR.

Maybe learning its tools will be an excellent investment if you want to be a front-end developer. But what if not?

We wrote this article mainly for beginners full stack developers. They are not well-experienced front-end developers.

Re:Modern Front-end in Rails by demiazz on Friday December 08, 2017 @06:37PM (#15883064)
Another case. My case.

My project started more than four years ago. It was a mainly content project around content creating and sharing, and of course SEO.

Facebook released React two month early than we started. Webpack has not yet created. Gulp is a bleeding edge. And we used sprockets, CoffeeScript and SASS.

It's is a massive project now. And it changed development vector for last year. We make a lot of changes, and we haven't resourced for rewriting them on separated front-end and back-end for now.

But described methodology allows us to keep this project maintainable. We migrated this approach from Sprockets to Gulp, and from Gulp to Webpack.

And we thought. What if we tell about how we maintain the project to beginners? They are writing jQuery-spaghetti code, and they may don't know frontend frameworks and Webpack.

Let's tell them how to write maintainable code with webpacker, components, BEM and our code organization. It's maybe a good starting point for them.

Re:Modern Front-end in Rails by oelmekki on Saturday December 09, 2017 @10:31AM (#15886190)
Did you try create_react_app? I find it way easier to setup my frontend using it than to use webpacker, even being used to both rails and react. You type "yarn build", and you have properly fingerprinted js and css files ready to use, with an `index.html` file that includes them. It's great to only focus on backend in rails, and it brings all the cool thing from js dev for free: babel, webpack, yarn, live reload, import of css files, etc.

SSR is indeed still a problem (I've build a cache system that will render pages with chrome headless, for that), but gladly, it's about to be solved (at least for the SEO part): https://webmasters.googleblog.com/2017/12/rendering-ajax-cra...

The biggest problem yet to be solved: properly handling 404 status.

Re:Modern Front-end in Rails by demiazz on Friday December 08, 2017 @06:42PM (#15883098)
We did not set a goal to teach well-experienced front-end developers how to organize their code. The well-experienced developer knows about many ways of code organization and can choose one for a project depending on the situation.