SIGN IN SIGN UP
withastro / astro UNCLAIMED

The web framework for content-driven websites. ⭐️ Star to support our work!

0 0 109 TypeScript

Skip SSR build for fully static Cloudflare sites (#16468)

* Skip SSR build for fully static Cloudflare sites

- Cloudflare adapter now passes through buildOutput from core instead of
  hardcoding 'server', allowing static sites to skip the SSR environment build.
- Server islands plugin upgrades buildOutput from 'static' to 'server' when
  server:defer components are discovered during prerendering.

* Use @cloudflare/vite-plugin pre-release from PR #12788

Adds minimumReleaseAge exclusions for transitive Cloudflare deps.

* Fix: upgrade buildOutput after prerender build, not during it

Move server islands buildOutput upgrade from the vite plugin transform
(which runs mid-prerender-build) to static-build.ts (after prerender
completes). This avoids a directory path mismatch where the prerender
output is written to the static path but manifest injection writes to
the server path.

* Fix: detect server islands via plugin API, mutate buildOutput after prerender

- Expose hasServerIslands() on server islands plugin API
- After prerender build, upgrade buildOutput to 'server' if server
  islands were discovered (so SSR build, manifest injection, and
  runtime all use correct server paths)
- Capture prerenderOutputDir before mutation to avoid path mismatch
- Simplify writeMutatedChunks to use getServerOutputDirectory
- Update session wrangler config test for static build output path

* Add preserveBuildServerDir, stop mutating buildOutput in static-build

- Add preserveBuildServerDir adapter feature so adapters can control
  the server output directory for static builds (mirrors preserveBuildClientDir)
- Cloudflare adapter sets preserveBuildServerDir: true
- Extract hasServerIslands() from server islands plugin as a standalone
  exported function that accepts any BuildEnvironment
- Replace buildOutput mutation in static-build.ts with a needsServerBuild()
  helper that checks settings.buildOutput or hasServerIslands()

* Fix server islands guard to check for adapter, not buildOutput

* Fix preview for static sites with SSR routes and internal route handling

- Stop overwriting buildOutput after route scanning in preview command;
  let route scanning upgrade it from 'static' to 'server' when needed
- Skip static preview server when adapter provides a previewEntrypoint
- Use getClientOutputDirectory in static preview server to respect
  preserveBuildClientDir
- Exempt internal routes (e.g. server islands) from getStaticPaths
  requirement and static path matching

* Fix no-shadow lint error in server islands plugin

* Add changesets for astro and cloudflare

* Update astro changeset to minor with adapter usage example

* Use @cloudflare/vite-plugin devOnly to skip SSR build for static sites

Switch to @cloudflare/vite-plugin PR #13985 which adds a devOnly property.
Set devOnly to a function that returns true when buildOutput is 'static',
letting the CF plugin skip the SSR worker build and emit an assets-only
wrangler config for fully static sites.

* Update lockfile for @cloudflare/vite-plugin ^1.39.0

* Update pnpm-workspace.yaml

Co-authored-by: Emanuele Stoppa <estoppa@cloudflare.com>

* Split changeset into separate patch entries

* Update .changeset/cloudflare-static-buildoutput.md

Co-authored-by: Armand Philippot <git@armand.philippot.eu>

---------

Co-authored-by: Emanuele Stoppa <estoppa@cloudflare.com>
Co-authored-by: Armand Philippot <git@armand.philippot.eu>
M
Matthew Phillips committed
4cff3a107c3750ab5f0878a6b41836705282b771
Parent: 66593e3
Committed by GitHub <noreply@github.com> on 5/27/2026, 1:41:47 PM