|
|
Q: I have a few different views that include different sets of stylesheets. How do I accommodate that?
Use the :name parameter. For example:
# in layouts/application.rhtml
<% bundle do %>
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag "basic" %>
<% end %>
# in layouts/admin.rhtml
<% bundle :name => "admin_bundle" do %>
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag "admin" %>
<%= stylesheet_link_tag "basic" %>
<% end %>Q: I need to debug my JS and CSS, and having it bundled makes it VERY difficult to do!
Just tack on ?bundle_fu=false on any page's URL and it will bypass bundling.
This setting is stored in your user session and will not affect other users of the site. It will stay bypassed until you lose your session.
Q: How does bundle_fu handle yield blocks? wbsmith83
First, bundle_fu renders the content from the block using capture(&block). Then, it parses the rendered content & looks for js/css includes. It uses this list to build the bundle.
Bundle_fu also watches the content from the block for changes in development mode. If a change is made to the content, it will automatically trigger a regeneration of the bundle
Q: Bundle_fu is breaking my css image references. What's wrong?
There were a few issues with the relative URL rewriter in the CSS bundler. All that were reported have been resolved. Please update to the latest version of bundle_fu. If you still have problems, try the mailing list.
GOTCHAS
- All content inside of bundle do will be replaced with a single js and css include statement. Any other content will be lost. Be sure to only put css / js includes inside of the block.
- Scripts / stylesheets are detected by parsing the output and looking for include files. Comments are ignored, so if you comment out a stylesheet like this:
<% bundle do %> <%= javascript_include_tag "prototype" %> <!-- <%= stylesheet_link_tag "basic" %> --> <%= calendar_date_select_includes params[:style] %> <script src="javascripts/application.js" type="text/javascript"></script> <% end %>
The comment will be ignored and the css file will be bundled anyways. If you need to comment out a css file to perform an ie6 hack, put it outside the bundle block.<% bundle do %> <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag "basic" %> <% end %> <!--[if lt IE 7.]> <%= stylesheet_link_tag "ie6fix" %> <![endif]-->(it shouldn't be bundled anyways, since it's conditionally loaded)
- Conditionally loaded css files and javascript files gotcha:
Consider the following<% bundle do %> <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag "#{@theme || 'blue'}_color_scheme" %> <% end %>On development, this will work fine. The bundle.css file will be regenerated everytime the theme changes. However, on production, this will be effectively ignored, as the content is only regenerated once per server instance. To remedy this, change the name parameter:<% bundle :name => "bundle_#{@theme || 'blue'}" do %> <%= javascript_include_tag :defaults %> <%= stylesheet_link_tag "#{@theme || 'blue'}_color_scheme" %> <% end %>bundle_fu will generate a different bundle file for each instance of @theme, only once!
- External dependencies via querystring loading will not work:
<script src="/javascripts/scriptaculous.js?load=effects,controls" type="text/javascript"></script>
Instead, you'll need to include each javascript file as normal.
Sign in to add a comment

Sweet, I think I'm gonna give this a try!
I don't know if this will help anyone but here's a post of how I got bundle_fu working with dynamically generated (then cached) style sheets. I put is a few lines of code in the plugin to go into "bundle_fu=false" mode if files it's trying to combing/compress are missing.
http://mudabone.com/aietc/?p=775
doesn't work when using the facebooker (facebook.com API) plugin by chad fowler. it uses the tunneled URLs instead of the localhost URL.
Is it possible that bundle fu bundles files on every new pageload before caching it?
I'm observing, that there seems to be some 3-4 second delay after calling my site everytime i use bundle fu!
i'd be surprised if that was the case, but u never know...