94% Asset Optimization.... just hanging

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.

Any ideas?

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.

How’d you remove it exactly?

Think I just deleted these lines: https://github.com/roots/sage/blob/375b06a22bd61dcdc6d80b248812e9cb8c86a238/resources/assets/build/webpack.config.optimize.js#L11-L24

2 Likes

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.

I don’t believe those lines do the filename hashing. Try deleting the dist folder and re-running your yarn command.

Just ran into this… yarn build ran fine but yarn build:production stopped at 94% and referenced optipng

after removing node_modules and yarn.lock then re-yarning, everything finished up without any issue.

my project is running sage 9.0.9 in lando on osx

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.