Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I precompile assets in rails in development environment?

I want to manually precompile some assets in my dev environment (to check the content of the compiled js and css files) from the command line.

I am running

RAILS_ENV=development bundle exec rake assets:precompile

but my js and css are not compiled in the public/assets folder, only the images are. Any idea why that may be happening?

like image 318
Coffee Bite Avatar asked Apr 10 '12 01:04

Coffee Bite


People also ask

How do you Precompile an asset?

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 asset pipeline works in Rails?

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?

The clean it removes the old versions of the precompiled assets while leaving the new assets in place. Show activity on this post. rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.


1 Answers

Try adding this to your config/environments/production.rb :

config.assets.precompile += %w( *.css *.js )
like image 198
Justin D. Avatar answered Sep 29 '22 08:09

Justin D.