Has anybody on this forum tried out either of Webpack or Lineman? I’m trying to figure out the best way to use React in a Rails project. I built this tutorial using the react-rails gem and I’d like to make these other options work using an alternative.
Why an alternative? There are many projects, such as React-Bootstrap that have npm or bower modules. So far, my best, simplest option is to hope the module supports globals and to then manually copy the js file over to the vendor directory. I’ve been trying all the other alternatives, but, my lack of familiarity with the Javascript toolchain suggests that it will be a fairly big investment to go beyond using the ra.
I do, however, like the concept of being able to prototype JS heavy client side screens without Rails. I’ve been using the default react-tutorial setup, adding a few pages of my own, as well as jsFiddle (example here).
Webpack
Couple articles on Webpack:
- Setting Up Webpack with Rails
- WEBPACK IN THE RAILS ASSET PIPELINE
Lineman
- Lineman Website
- Lineman-Rails
A project I did with Thoughtbot this year (my current company’s app) used Bower, and I’ve become a big fan. Since our intitial implementation, I’ve moved from using Bower in my build script (via Heroku) to loading Bower assets via Rails Assets. Rails Assets “gemifies” your Bower packages, so you declare them via your Gemfile. Every Rails Assets package includes the proper =include
directives you need to use in application.js
or application.js.coffee
.
Here’s a blog post I wrote about moving to Rails Assets: http://blog.cortexintel.com/blog/2014/07/bower-through-rails-assets/. Whether or not you use it, I can’t recommend Bower strongly enough.
@Justin_Gordon turns out your question was very timely as we just today had a dev discussion about ‘Alternative Asset Pipelines’ which touched on our thoughts on splitting out client side apps and managing the build process outside of Rails.
You can see that post here: Alternative Asset Pipelines