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' ?
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.
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.
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.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With