Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between rake assets:precompile and rake assets:clobber

Can anyone please tell me the difference between rake assets:precompile and rake assets:clobber. really its a great confusion.

like image 906
Anitha Avatar asked Aug 20 '15 12:08

Anitha


People also ask

What does rake assets Precompile do?

rake assets:precompile. We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.

How do I Precompile assets in Heroku?

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.

What is pipeline assets?

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 and pre-processors such as CoffeeScript, Sass, and ERB.


3 Answers

You can precompile the assets in app/assets using rake assets:precompile, and remove older compiled assets using rake assets:clean. The rake assets:clean task allows for rolling deploys that may still be linking to an old asset while the new assets are being built. If you want to clear public/assets completely, you can use rake assets:clobber.

rake assets:clean # Remove old compiled assets

rake assets:clobber # Remove compiled assets

rake assets:precompile # Compile all the assets named in config.assets.precompile

like image 110
Nirajan Pokharel Avatar answered Oct 08 '22 18:10

Nirajan Pokharel


Note: rake assets:clobber also removes the assets directory completely.

To get the info on any rake tasks try this :

rake --describe | grep assets

This returns all the answers.

rake assets:clean[keep]
   Remove old compiled assets
rake assets:clobber
   Remove compiled assets
rake assets:environment
rake assets:precompile
  Compile all the assets named in config.assets.precompile
like image 22
Gary Avatar answered Oct 08 '22 18:10

Gary


the command rake assets:clobber removes/deletes all compiled assets. Whilst the command rake assets:precompile creates the compiled assets listed on parameter config.assets.precompile.

Please have a read on Rake's documentation for further information on it

like image 37
The Fabio Avatar answered Oct 08 '22 18:10

The Fabio