statamic / ssg

The official Statamic Static Site Generator
233 stars 24 forks source link

Make reusing Glide cache directory easier #89

Closed ncla closed 2 years ago

ncla commented 2 years ago

This PR helps improve the situation with these two issues https://github.com/statamic/ssg/issues/55 https://github.com/statamic/ssg/issues/56

Most of my thinking is already written in #55 but I will outline it again. I have made reusing Glide cache directory easier by:

  1. Moving content generation step after files/dirs have been copied or symlinked.
  2. Allow to skip clearing SSG output directory via config option

Both things give more freedom for developers to move/copy/symlink any content in the output directory. First one is useful if you are just using the ssg.php config file to copy the cache. The second one is useful if you are copying cache outside and before the ssg:generate step.

There is no issue with Glide/Flysystem as Jason initially thought (phew!)

I also added instructions on how to reuse cache easily on Netlify. I do this for one of my sites already and I saw about 66% decrease in build times. :rocket: I have a lot of Glide manipulations.

jasonvarga commented 2 years ago

Hey @ncla sorry for the delay, but if I'm understanding correctly, this issue should be solved by using a custom Glide filesystem as per https://github.com/statamic/cms/pull/5725

Docs here: https://statamic.dev/image-manipulation#custom-path-static

You could set the glide cache location to within the static directory.

jasonvarga commented 2 years ago

I looked into an issue and noticed the reason for closing this was very much incorrect. We're overriding the Glide cache in the ssg so my suggestion wouldn't work. Sorry about that!

ncla commented 2 years ago

All good, I wanted to check myself if the new changes actually fixed this issue but I got assigned a new project so I couldn't check in timely manner.

jasonvarga commented 2 years ago

These are good changes, I'll sort them out. There's a few edits I'll need to make. I'll either push them to your branch or bring your changes into my own PR. Thanks again for this.

jasonvarga commented 2 years ago

Okay I'm going to open a separate PR but take yours as inspiration.

I don't want to reorder the symlinking/copying as this could be a breaking change for people. For your use case, you could use the SSG::after() callback to create symlinks or copy directories.