maybe Im asking too much, but I want you, Rails developers to share your
assets pipeline configurations.
Im really loving Rails but some things doesn’t fit in my head and I need
solutions (this perfectionism will kill me someday :P)
Is not THAT bad having all CSS and all JS compressed into one file (I
think that having an import on every erb is not that bad). The problem
is when you have third party css like ActiveAdmin’s one that conflict
with your own CSS.
I think that the default options are not the best, just a starting.
I will share what actually work for me and I hope to see if my solutions
sucks and what are your solutions.
One idea is:
Remove require_tree from “application.js” and “application.css”.
In application.html.erb change:
<%= stylesheet_link_tag “application”, controller_name, :media =>
So in a controller I’ll have my app js/css and my controller js/css.
If a controller need more deps, I can add them on the views or in the
js/css (like in app js/css).
Next, I add every controller js / css into production.rb like:
config.assets.precompile += %w( people.css languages.css people.js
So I get a compiled css for every controller and a compiled js for every
controller. The only downside is to add all extra stuff on
What you think? Maybe have flaws, dont know.
On ActiveAdmin screencast, I saw that a solution is to remove
“require_tree” and then convert the application.css to sass and then:
For every css. And same for js.
Is the same stuff as solution 1 but having ALL css/js in the same file.
So, can you share your ideas and criticize my solutions?