FUCK ANGULAR 2 ON rails lessons learned

Let’s be honest, the asset pipeline is pretty shitty. I definitely hate it. But sometimes it’s best to accept its existence, move forward, accept it and utilize it.

I’ve spent the last 5 days fighting the asset pipeline attempting to get Angular2 to place nicely with Rails. With all the dependencies and bullshit that comes with Angular2, I found it really difficult to implement into Rails. I had Gulp processes going, I implemented npm, I had dual build packs with heroku, I did ALL SORTS OF BULLSHIT. LITERAL BULLSHIT. Let me save you a few days of time…


Angular2 gave up on bower. They’re like fuck bower. And I say, fuck angular for that. I used bower to manage my dependencies and switching to npm was a complete pain in the ass. It was always a catch 22 - I do it this way and that f’s something else up.

These past 5 days, I was just being stubborn. I wanted that feeling of oh yea, I implemented Angular2 on my app and I’m cutting edge. My ego got in the way of making progress. The frustration also forced me to learn a lot about the asset pipeline, babel and javascript. And I also learned about my asset hero, react.

Why React Kicks the shit out of Angular2

React can be implemented with a simple gem, react-rails. React has very little dependencies.

Then if you add sprockets-es6, you can save javascript files in .es6.jsx and they’ll be transpiled into .js in a form that most browsers will understand.

React is basically built for something like rails. It’s just views. Man, just the views. That’s all we need to fuck with! Where as Angular 2 needs all these various files. Omg, React is just so much more simple.

You can drop react components in your views easily

<%= react_component "ExampleComponent" %>

Easy to use generators rails g react:component ExampleComponent name:string

Now I can get back to coding and not fucking around with setup!

Post Content