Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Asset Pipeline

Francisco Garcia edited this page Aug 15, 2014 · 3 revisions

There are multiple assets available, one for each gem and a central shared one.

The gems are expected to get common assets from the pademo-base pipeline like in:

http://localhost:9292/assets/application.css

Source:
/vendor/pademo-base/app/stylesheets/application.css

Likewise the stylesheets for pademo-foo can be found at:

http://localhost:9292/foo/assets/foo_style.css

Source:
/vendor/pademo-foo/app/stylesheets/application.css

Sprockets

Sprockets is a well known pipeline used in Rails and very easy to setup with the padrino-sprockets gem

Grunt

Grunt has been considered because others had problems in projects using lots of Javascript code.

Unfortunately this greatly complicates Pademo setup and deployment when sharing assets among gems. In my case it was adding an import path of my common SCSS files to Compass. If your assets need to import files from pademo-base (using the filesystem and not the url) you can reach its contents using the Gem library like this:

Gem.loaded_specs['pademo-base'].full_gem_path

Because Grunt is implemented in Javascript you cannot use the above call to to locate your shared asset files. You could use git submodules but that makes everything more complicated requiring extra repositories that needs a cycle of push/pull with each modification. Packaging assets within a Gemfile is a much easier workflow.

Using Grunt also involves adding the typical NodeJS definition file application.json, which also increase the complexity of your deployments.

Although Grunt still seems promising, migrating from Sprockets seemed to cause more pain than pleasure, specially considering that we did not get any benefit that justifies the migration effort.

Notes:

  • With Grunt you will not be able to rely on Padrino auto-reload feature, that can be solved using Foreman.
  • Having common assets in a central place without constant push/pull for each gem is important for your sanity
  • A possible solution to share information (unique for each machine) between Ruby and NodeJS tools could be environment variables.
  • Production deployment with Capistrano + NodeJS has some hope. There are gems like capistrano-grunt and capistrano-npm
Clone this wiki locally