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 => "all" %>
<%= javascript_include_tag "application", controller_name %>

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 languages.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 "production.rb"

What you think? Maybe have flaws, dont know.

Solution 2:

On ActiveAdmin screencast, I saw that a solution is to remove "require_tree" and then convert the application.css to sass and then:

@import "controller_css";

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?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/E4NNqGH5YuwJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Robert Walker at Feb 14, 2012 at 11:37 pm

    Foxandxss wrote in post #1046631:
    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.
    Every asset a web browser requires needs a separate connection. If it's
    possible to include all JS in one file and all CSS in another file the
    browser only requires two connections. If the JS and CSS are broken into
    multiple small files the browser must create many separate connections
    to get them all.

    AFAIK this is the primary reason the default convention in Rails is to
    compile all JS and CSS files together in a single resource for each.
    When adding gzip this method can significantly improve performance.
    On ActiveAdmin screencast, I saw that a solution is to remove
    "require_tree" and then convert the application.css to sass and then:
    Framework code that contains it's own JS and CSS should really be
    name-spaced in such a way as to not interfere with your own custom code.
    That's not to say that all of them do so.

    JavaScript and CSS are not natively name-spaced. Just having the code in
    separate files will not prevent namespace collisions.

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 14, '12 at 9:52a
activeFeb 14, '12 at 11:37p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Robert Walker: 1 post Foxandxss: 1 post

People

Translate

site design / logo © 2022 Grokbase