rails asset pipelineThe rails asset pipeline provides a simple framework to concatenate and minify or compress JavaScript and CSS files. To learn more about the rails asset pipeline I suggest viewing the railscast or reading the rails guide.

However both of these resources leave out a minor detail, which took me too long to figure out. Adding //= require_tree . to the main manifest file does not recurse into the lib and vendor assets directories. There are a number of ways to solve this issue but none very elegant. The simplest way to require all assets, is to add the following to the app/assets/javascripts/application.js file.

//=require_tree ../../../vendor/assets/javascripts/.

Something similar can be done in the app/assets/stylesheets/application.css file. The point here is there is very little magic going on. The require statements in these manifest files are quite literal.

If you find yourself requiring too many files from the vendor and lib folders, and don’t like to look too many ../../vendor paths in your manifest file. The you can always create a specific manifest file for your assets in the lib and vendor folders, such as vendor/assets/javascripts/vendor_application.js. You can then proceed to require your files from there. In this case you will still need to require this file from your app/assets manifest file.