Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does require_tree require files inside 'vendor/assets' and 'lib/assets' ? - Rails

I came to know that during pre-compilation of assets in production mode, Rails will take assets from 'app/assets' only by default if we do not require files explictly from any other specific sources like 'vendor/assets' and 'lib/assets'.

I've a question:

Will require_tree . load assets from 'vendor/assets' and 'lib/assets' ?

like image 441
Rajesh Omanakuttan Avatar asked Mar 06 '14 05:03

Rajesh Omanakuttan


People also ask

How do you Precompile rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

How does Rails asset pipeline work?

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB. Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets.

What does rake assets Clean do?

rake assets:clean Only removes old assets (keeps the most recent 3 copies) from public/assets . Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.


1 Answers

No, require_tree . will only load the assets in the local directory, hence the dot after require_tree, which specifies only the directory where the application asset file exists. If you want to include files in vendor/assets and lib/assets, you should do something like this (or similar for stylesheets):

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

(From this question.)

like image 134
jvperrin Avatar answered Sep 23 '22 03:09

jvperrin