Adds a new "astro:build:generated" hook for SSG builds
This feature was originally reviewed in #4772 but accidentally merged in as a minor release too early. #4774 reverted the feature to avoid blocking patch releases
Changes
This adds a new astro:build:generated hook that runs after all SSG pages are generated but before build artifacts are cleaned up.
Why?
This handles a very specific use case for @astrojs/image. The new wasm-based image service uses a worker pool to build multiple images in parallel. The workers need to reference the build's main entrypoint bundle before it's removed by the cleanup process
Alternatives considered
- fire
astro:build:donebefore the cleanup process
This would technically be a breaking change, and feels a little gross in general since the build really isn't done until it's finished cleanup and is exiting
- refactor the SSG image service to build images during the page generation rather than building all images at the end.
This is a huge performance hit, doing all images at once allows the process to read a local image file once and build all needed versions at once without hitting fs.readFile again
Testing
Test added to make sure the event fires with the correct output directory
Docs
Docs PR #1572
/cc @withastro/maintainers-docs for feedback!