I made a rails plugin for using juicer. Check it out at
http://github.com/ktheory/juicer-rails
The plugin make it easy to use uncompressed assets in development
mode, and compressed assets in production.
It adds a `juiced_tag` method to use in your views. Use juiced_tag
instead of `stylesheet_link_tag` and `javascript_include_tag`.
In development mode, juiced_tag resolves the dependencies of the
argument and returns a <script> or <link> tag for each dependency. In
production, it returns a single tag for the juiced asset. See the
README for more:
http://github.com/ktheory/juicer-rails/blob/master/README.rdoc
Currently, the plugin doesn't build the assets automatically. That's
left for your deployer.
If you find bugs or want to suggest features, open an issue at
http://github.com/ktheory/juicer-rails/issues
Cheers,
Aaron Suggs
Thanks!
> I've been thinking alot about how and when files should be built. Requiring
> files to be built as part of deployment definitely is the solution with the
> lowest overhead on the app side of things. For this purpose it would be nice
> if juicer-rails featured a rake task, or maybe even a capistrano recipe to
> get this done easily. The problem with this approach is that it could be
> hard to automatically get a list of all files that should be produced (or
> not? could parse view files I guess). There are some alternatives out there,
> and all of them require configuring up targets, which I think we should
> avoid.
Indeed, this would be nice to have, and should probably be built in to
juicer-rails. :-)
http://github.com/ktheory/juicer-rails/issues/issue/1
Getting the list of target assets is the difficulty. Parsing the views
or using a YAML config file would be straightforward, but they feel
inelegant. I'd like to leverage convention over configuration as much
as possible.
> The other idea I've had is to have a Juicer controller that can build files
> the first time they're requested.
Excellent idea. This could even be Rack middleware to be
Rails-agnostic. The middleware should probably be it's own project
since it's useful independent of juicer-rails.
juicer-rails answers the question "which script/link tags should I
include on this page?"
The middleware answers "what content should I serve back for a this asset url?"
Even with the middleware, there's good reason for a juicer-rails rake
task to build the assets at deploy time:
- static files may be served from different machines than the app servers
- thundering horde problem generating large assets for the first time.
Thanks again Christian (et al) for making juicer.
Cheers,
Aaron
On Sun, Jan 24, 2010 at 1:29 PM, Christian Johansen <chri...@gmail.com> wrote:Getting the list of target assets is the difficulty. Parsing the views
or using a YAML config file would be straightforward, but they feel
inelegant. I'd like to leverage convention over configuration as much
as possible.
Excellent idea. This could even be Rack middleware to be
> The other idea I've had is to have a Juicer controller that can build files
> the first time they're requested.
Rails-agnostic. The middleware should probably be it's own project
since it's useful independent of juicer-rails.
juicer-rails answers the question "which script/link tags should I
include on this page?"
The middleware answers "what content should I serve back for a this asset url?"
Even with the middleware, there's good reason for a juicer-rails rake
task to build the assets at deploy time:
- static files may be served from different machines than the app servers
- thundering horde problem generating large assets for the first time.
Thanks again Christian (et al) for making juicer.
Cheers,
Aaron