<Project id="gatsby-postbuild" />
Gatsby Postbuild
Provides an easy way to transform, modify or optimize static files generated by Gatsby.
Project Overview
Gatsby plugin that adds a file processing pipeline that runs after gatsby build to transform and optimize the files in /public. It ships ready-to-use tasks (PurgeCSS, HTTP headers, Minify) and supports adding custom tasks that hook into file-type events (e.g., HTML AST) or generic file events.
Key Features
- Provider headers generation: emits hosting configs (e.g., Firebase, Netlify, Vercel) for resource hints, caching, security and other critical headers.
- Built-in tasks: PurgeCSS, HTTP headers (provider presets), Minify (terser/cssnano).
- Custom tasks via events: register handlers for generic
contentsor HTML events likeparse,tree,node,serialize,write. - Processing controls: choose parallel or sequential strategies and set concurrency globally or per task.
- Ignore & per-task filters: exclude files globally or per task.
- Reporting: optional
postbuild.log.jsonand console summary with toggles.
Why
- Close the “last mile”. Gatsby stops at generating
/public; teams hack the rest in CI scripts. Postbuild provides a structured, repeatable stage for that work. - Put critical headers at the edge. Generate provider configs so browsers/crawlers receive resource hints in the first response, enabling action before the page HTML is parsed.
- Make builds reproducible. Run the same tasks locally and in CI, with clear logs and one config.
- Unify common optimizations. PurgeCSS, minification, HTTP headers, redirects, and custom file transforms—all in one pipeline.
Check out the project repository on Github for more info.