Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Using Sprockets outside of a Rails app #348

tubbo opened this Issue · 7 comments

6 participants


According to the documentation, and everything I've ever read about it, the idea of using Sprockets for asset management in a non-Rails project is impossible. The rake/sprocketstask library does not exist, or can't be loaded in the manner that the README states. These tasks have been moved to lib/tasks/assets.rake on the rails/sprockets-rails repository. In order to properly precompile tasks for production use, you must require rails and hack your way around this problem.

Is this project meant to be used outside of the Rails world? It's title, "Rack-based asset packaging", insinuates that this is compatible with any Rack app, rather than being coupled to only Rails apps. If it is true that the project's goals are to work with any Rack setup, these Rake tasks need to be available on the server, and preferably in Capistrano so we can invoke precompilation from the local machine, rather than having to SSH into the production box.

Before I proceed in troubleshooting this, I was wondering whether this was a design decision or simply an oversight since 99.99% of Sprockets use comes from Rails, and to my knowledge it was developer for Rails. But I think it would be cool if you could use the "asset pipeline" outside of a Rails app, with whatever framework you like, so that's why I'm raising this right now. :)


I've used sprockets outside of rails projects, and the rake/sprocketstask task is available outside of Rails, can you describe what exact issues are you having?

The tasks haven't been moved to lib/tasks/assets.rake, (the tasks in sprockets-rails are duplicating the one included in sprockets) and I'm planning to rewrite all the tasks in sprockets-rails to use rake/sprocketstask


There's a few examples of Sprockets with rack and sinatra at maccman/catapult and maccman/stylo repos.


I feel your pain, but Sprockets definitely can work outside of Rails. Take a look at l3ck/sinatra-boilerplate for an example of how to set it up (that's my starting place with new Sinatra apps). I couldn't get the Rake tasks working but you can get around a lot of that anyway.


I'm a little late to the part on this one. Which version of Sprockets are you using? I had the same issue when I simply had gem 'sprockets' in my Gemfile. For some reason, it installed Sprockets 2.1.3 which does not include the Rake task. After I explicitly told bundler to update Sprockets, everything worked fine.


Get the latest sprockets.

@josh josh closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.