google / eleventy-high-performance-blog

A high performance blog template for the 11ty static site generator.
https://www.industrialempathy.com/posts/eleventy-high-performance-blog/
MIT License
4.01k stars 283 forks source link

Build took too long because one image #102

Closed hifedixx closed 3 years ago

hifedixx commented 3 years ago

I'm migrating my blog to Eleventy and tried to deploy it on Cloudflare, but it failed in every build. So I moved to Netlify, and it turns out that my build took up to 30 minutes. And there is a single image that needs 20 minutes itself.

netlifybuild

The pic is about 4MB in size. Is it too big?

ZoltanVeres commented 3 years ago

Run the npm run build locally on your machine, that will generate all the images needed. Then run persistimages.sh which will move all generated files to_site/img folder which is persisted during builds. Make sure you commit the images When the changes are getting pushed, Netlify picks them up and eleventy hopefully will skip processing the images. If you send link to the original image then we could probably able to diagnose why this is getting processed so slowly, it's maybe an issue coming from upstream, i'm thinking sharp generally tends to hang when the build happens in a serverless environment.

hifedixx commented 3 years ago

I don't use remote image, I've downloaded it before and place it in the img folder. But what I get from what you said, we must run persistimage.sh so Netlify doesn't need to proccess the imgs again. Then the build time will be much shorter. Is that right?

mufidu commented 3 years ago

You can set .persistimage.sh to be a part of the build process in package.json's script. Mine looks like this:

"build": "npm run js-build && eleventy && ./.persistimages.sh",
cramforce commented 3 years ago

+1 This works both for local and remote images.

hifedixx commented 3 years ago

Thanks everyone! Solved.