Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Latest commit

 

History

History
35 lines (24 loc) · 2.36 KB

motivation.md

File metadata and controls

35 lines (24 loc) · 2.36 KB

Motivation

Rails's asset pipeline was a great step forward for Rails 3. For today's requirements however, it doesn't always come with all the tools you need. Here's a portrait of Rails's shortcomings with respect to CSS/JS development in 2016:

  • npm assets: Frontend packages are now usually hosted in npm, but there's no easy solution to integrate npm with Rails. Putting files into vendor/assets should be a thing of the past.

  • Auto-reload: Automatic CSS reloading can be done with guard-livereload, but is unwieldy at best. They require too much configuration and mental overhead to maintain.

  • Modern CSS tools: Integrating modern CSS tools like libsass and postcss can be done, but is hackish and slow. It has to invoke a separate Node.js process for each CSS file rather than keeping those tools running in the background. Some newer CSS pre/post processors like Myth don't have production-grade integrations with Rails.

  • Modern JS tools: Working with complex frontends typically need Webpack or Browserify. While integrations for these exist, they can be slow and unreliable.

Using Node.js

npm-pipeline-rails lets you outsource asset building complexities to Node.js-based tools, which is the gold stardard for asset tooling nowadays.

It doesn't lock you into one specific solution; you can use npm-pipeline-rails for any task manager. I recommend Brunch for its ease-of-use and familiarity with Rails's asset pipeline's features. Gulp and Grunt are also popular choices.

Brunch

You can use Brunch with Rails with ease using npm-pipeline-rails. With Brunch, you get automatic code reloading, easier integration with postcss, require() support, and more. You may even hook Browserify if you need it.