We recently started another new Bedrock/Sage project here, and the last 8 or so have been fine. This latest one, on a yarn build:production just sits there at 94%.
Tried on multiple systems, and always the same issue. No errors, just hangs for forever.
I think I ran into a similar error at that same point (94%) that ultimately had to do with the ImageMin plugin webpack is using. In my case I didn’t need the image optimization (I was doing that by hand) so I just ripped it out and everything worked. If you need the plugin, you may be able to massage it a little to get it to work better. IIRC it can have some issues because it depends on system-level libraries to do image compression.
Awesome, removed that and the site can actually be built for production now. Not sure what changed, I have 10+ other Bedrock/Sage sites locally that still compile just fine.
Ah damn, removing just those lines and the site is still creating files like dist/images/logo-1b02f538.svg but the site is now just looking for the non-hashed ones.
It tends to hang when you have a lot of PNG images to process. Check out this (merged) PR for related discussion:
I believe it should be applied for the version of Sage you are using, but if you are still processing a load a PNGs, who knows. I would experiment with disabling optipng all together, since pngquant will still do a great job optimizing on its own.