linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 83 forks source link

Trying to do react-rails-tutorial with lineman #313

Closed justin808 closed 9 years ago

justin808 commented 9 years ago

I'm trying to make this tutorial (https://github.com/justin808/react-rails-tutorial/tree/react) work with lineman.

I've created this repo: https://github.com/justin808/react-tutorial-lineman. The commit history shows the steps I've taken. I've followed the basic steps listed in the http://linemanjs.com/ page.

On a side note, I'd like to be able to publish assets to rails non-minified, and then use rails to minify before publishing. Any idea on how to do this or why it's not necessary?

Any help is greatly appreciated.

Justin

Posted to Ruby Rogues Forum

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:

  1. Setting Up Webpack with Rails
  2. WEBPACK IN THE RAILS ASSET PIPELINE

    Lineman

  3. Lineman Website
  4. Lineman-Rails
davemo commented 9 years ago

Hi @justin808, I went through a large integration project using Lineman + Rails; while I don't remember everything and I don't have access to the code anymore here's some of the highlights and pain points I can remember:

  1. If the organization is staunchly in favor of "the rails way" you may have to modify bootstrap.rb to hook into the right time to process assets with lineman so as not to negatively impact peoples workflow who don't touch frontend assets and don't want to have to use both lineman run and bundle exec rails server at the same time ; YMMV :P
  2. If your goal is to publish unminified assets into the right spot inside of rails I would probably look at adding custom grunt-contrib-copy targets to config/application.{js,coffee} that will move assets from linemans generated folder into rails' public/assets.