You can clone with
HTTPS or Subversion.
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: https://github.com/middleman/middleman-sprockets/blob/master/lib/middleman-sprockets/extension.rb#L63
Is that not what you mean?
Yeah, I thought so too, but in my extension:
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:
This is fixed on Middleman master now.