I remember being really excited for Rails
3.1, and that’s because it was going to have ‘the asset pipeline,’ helping us manage the assets our application needed. I also remember being so excited by it, I fooled around with sprockets
2.0.0.beta6 to get it running on my Sinatra apps, as well. It took me a while, and when
beta7 came out, it didn’t work any more…
But this isn’t a story about me. It’s a story about Joakim Ekberg. He did better than I ever did: when he put Sprockets on Sinatra, he made a gem out of it. He calls it
It’s pretty easy to use: just
in your Gemfile. After bundling, add this to your Rakefile:
require 'sinatra/asset_pipeline/task.rb' Sinatra::AssetPipeline::Task.define! MyApp
and add it to your application, too:
require 'sinatra/asset_pipeline' class MyApp < Sinatra::Base register Sinatra::AssetPipeline end
sinatra-asset-pipeline gives you the rake tasks you’d expect:
$ rake assets:precompile $ rake assets:clean
Sinatra-asset-pipeline is still pretty young, and currently only supports the stock Haml, Sass, and CoffeeScript options that the Rails asset pipeline uses. Hopefully, future releases will integrate Tilt so that you can use arbitrary endings, but there’s a reason why these are default in Rails: they’re the most popular alternate options from the defaults.
Have comments? Send a tweet to @TheChangelog on Twitter.
Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.