Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Expose Sprockets environment to extensions #20

datapimp opened this Issue · 5 comments

3 participants


When middleman-sprockets is used, it would be nice to be able to access the sprockets environment in other extensions.

From looking at the code, it does seem as if I should be able to access it in the app variable that gets passed to the registered method. However it may be a load order problem, but my current attempts in the middleman extension I am writing have not been successful.

I will include a pull request when I figure it out. Any advice in the meantime would be appreciated


You're on the right track and I think the solution shouldn't be too difficult. Happy to help out with the PR


I think you can access the Sprockets environment already via the sprockets method on the middleman application. It's defined here:

Is that not what you mean?


Yeah, I thought so too, but in my extension:

  module CodeSync::MiddlemanExtension
    class << self  
      def registered app
        app.send :include, InstanceMethods

        raise unless app.respond_to?(:sprockets)

This actually raises an error. And I confirmed that the middleman-sprockets extension was being loaded prior to it. So i'm not sure what is going on exactly.

It seems like there may be some issues with the autoload_sprockets behavior in middleman-core extension code.

The app is using middleman-core 3.0.13 which doesn't seem to have the updates you made here:


I will keep investigating


I know why this is - we register the :sprockets extension too late. I'm fixing this on middleman master, but for now you can do:

app.after_configuration do
  sprockets.append_path "whatever"

This is fixed on Middleman master now.

@bhollis bhollis 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.