Can anyone please tell me the difference between rake assets:precompile and rake assets:clobber. really its a great confusion.
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.
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 and pre-processors such as CoffeeScript, Sass, and ERB.
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
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
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
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