Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent overwriting the manifest in the first phase of the build #63

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

jagthedrummer
Copy link
Contributor

@jagthedrummer jagthedrummer commented Sep 10, 2020

Since we store the optimization manifest in the build directory, and since it doesn't have a counterpart in the source directory the ManifestResource needs to behave a little differently than your average resource. Instead of reading a file from source and writing it to build we want to read from build if the file already exists, so that we preserve the contents of that file through the first stage of the build.

In one of my projects this PR takes a 22 minute build down to 2 minutes.

Fixes #60
Fixes #41, Closes #58 (Specifying the manifest path shouldn't be needed if we don't overwrite it, and storing it outside the build directory doesn't exactly make sense since it is an artifact of a particular build, or sequence of builds. To say it another way, if you used an existing manifest with an empty build directory you'd end up skipping optimization of images that would need to be optimized.)

Copy link

@KevinBongart KevinBongart left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this! I authored à related bug fix but looks like yours is a better soltion

@@ -29,10 +29,11 @@ def ignored?
private

def manifest_content
if @source_file.nil?
path = File.join(@app.config[:build_dir], @destination_path)
if !File.exist?(path)

Choose a reason for hiding this comment

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

Nitpick but this would be generally easier to understand using the positive form:

if File.exists?(path)
  do B
else
  do A
end

Instead of if !x do A else do B

@johnvuko
Copy link

johnvuko commented Jan 4, 2022

Any news on merging this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Imageoptim taking much longer with Middleman > 4.3 Specify manifest file path
3 participants