Skip to content

Commit

Permalink
after_build should be inside after_config to respect ordering of conf…
Browse files Browse the repository at this point in the history
…ig.rb
  • Loading branch information
jeffutter committed Dec 30, 2013
1 parent 8201647 commit a503498
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/middleman-imageoptim/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ def registered(app, options_hash = {}, &block)
options = Middleman::Imageoptim::Options.new(options_hash)
yield options.user_options if block_given?

app.after_build {|builder|
Middleman::Imageoptim::Optimizer.new(app, builder, options).optimize!
}
app.after_configuration do

app.after_build do |builder|
Middleman::Imageoptim::Optimizer.new(app, builder, options).optimize!
end

end

end
alias :included :registered
end
Expand Down

1 comment on commit a503498

@ewlarson
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I disagree here and the MM forum does, too
http://forum.middlemanapp.com/t/order-of-after-build-callbacks/901/8

"...But if you look at the sync extension, it registers its after_build callback inside an after_configuration callback, which gets run after everything in your config.rb has been processed. So no matter when you activate sync, its after_build stuff gets added after cloudfront's..."

I'm seeing file permissions not preserved when I activate imageoptim, so I wrote a quick shell script to run in the after_build callback to properly set all the image files in my build/images directory to sane file permission settings.

If this gem's after_build block is inside after_configuration, the order I activate my extension (runs my shell script) is not preserved. When no after after_config block exists, the order I activate extensions is preserved.

Please sign in to comment.