fredjean/middleman-s3_sync

Unnecessary build of external asset pipeline on sync?

mathie opened this issue · 4 comments

I'm trying to speed up my deploy pipeline a wee bit. I'm using gulp as an external pipeline in Middleman, configured with:

activate :external_pipeline,
  name: :gulp,
  command: "./node_modules/gulp/bin/gulp.js #{build? ? 'build' : 'serve'}",
  source: 'intermediate/'

When I run middleman sync (without the --build option), it's still kicking off the external pipeline, and rebuilding all the external assets. My feeling is that it shouldn't be doing that.

I think the external pipeline plugin is kicking off a build on initialisation, rather than hooking in as a before/after build step, so I think the fix lies in middleman itself, but I thought I'd solicit your opinion. One way to fix it would be to expose a sync? method in the same context (like build?) and I could just make command a noop if sync? evaluates to true...

What do you reckon?

Oh, the entire repo is up at wossname/www.rubyonrails.co.uk if you want to poke around at the rest of the config. 😄

Hi @mathie . We need to set the mode to build so we get the whole sitemap as the source of paths to evaluate when deciding what to sync. (At least I am pretty sure that we need to).

Good timing, I was just about to follow up with the tidbit I got from Thomas on the main repo:

Setting config[:mode] to :config should work, in that extension.

I have no idea if that works, but I’m willing to do a bit of testing today, so I’ll soon find out. :)

G

On 18 May 2016, at 04:31, Frederic Jean notifications@github.com wrote:

Hi @mathie https://github.com/mathie . We need to set the mode to build so we get the whole sitemap as the source of paths to evaluate when deciding what to sync. (At least I am pretty sure that we need to).


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #124 (comment)

iaman commented

Just spent half a day trying to figure this out, so I thought it might be worth renewing interest in this discussion:

The existence of this behavior warrants a warning that this gem will not function on a site with generated assets that have any degree of randomness to them, when combined with asset hashing. This is because the following happens:

  1. The middleman app starts
  2. The gem gets the list of built assets from middleman
  3. Assets get built with new random values, removing the old file from the build directory and replacing it with a new one (with a new SHA at the end of the filename)
  4. The gem cannot find the file it expects (the old filename) when it is checking to see if it needs to push to S3

As discussed above, there would probably need to be a core middleman change to get the sitemap of built assets without triggering a build. In the meantime, would it be at all possible to at least wait until after the assets are rebuilt to get that sitemap and guarantee it is correct at time of execution?