Using Sprockets outside of a Rails app #348

Closed
tubbo opened this Issue Aug 3, 2012 · 7 comments

Comments

Projects
None yet
6 participants

tubbo commented Aug 3, 2012

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

tubbo commented Aug 3, 2012

Well when I try and require "rake/sprocketstask", I get "cannot load such file". Same goes for when I require sprockets before that line. Haven't been able to figure out a solution to this for a few months. How are you requiring the file?

Also, is the "deploy/assets" cap task file (loaded in Capfile) from sprockets-rails or sprockets itself?

On Aug 3, 2012, at 3:28 PM, Guillermo Iguaranreply@reply.github.com wrote:

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


Reply to this email directly or view it on GitHub:
#348 (comment)

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.

tubbo commented Dec 19, 2012

That's a problem I've noticed with a lot of other gems, I think it may be a Bundler issue. When in doubt, specify your version with '~>'

On Dec 19, 2012, at 9:42 AM, Brad Gignac notifications@github.com wrote:

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.


Reply to this email directly or view it on GitHub.

Contributor

josh commented Feb 7, 2013

Get the latest sprockets.

@josh josh closed this Feb 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment