Skip to content

Treat Vite's resolved outDir values as the source of truth for build output - #18112

Merged
ematipico merged 7 commits into
withastro:nextfrom
jamesopstad:resolved-vite-output-dirs
Sep 25, 2026
Merged

ematipico merged 7 commits into
withastro:nextfrom
jamesopstad:resolved-vite-output-dirs

Conversation

@jamesopstad

Copy link
Copy Markdown
Contributor

Changes

Astro now treats Vite's resolved outDir values as the source of truth for build output. Generated assets, build hook dir values, and SSR manifest paths use the resolved client, server, and prerender directories. Custom prerenderer factories also receive these directories through a new context argument.

Additionally, manifest cleanup is now deferered until all buildApp hooks have completed, allowing platform plugins to consume the manifests.

Testing

Tests added to validate that the new behaviour. Existing tests validate that this change hasn't broken output directory path handling.

Docs

This is primarily an internal change but is relevant to integration authors.

@changeset-bot

changeset-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 021eae7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
astro Minor
@astrojs/cloudflare Patch
@astrojs/markdoc Patch
@astrojs/mdx Patch
@astrojs/netlify Patch
@astrojs/node Patch
@astrojs/svelte Patch
@astrojs/vercel Patch
@astrojs/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added semver: minor Change triggers a `minor` release pkg: astro Related to the core `astro` package (scope) docs pr labels Sep 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 21 untouched benchmarks


Comparing jamesopstad:resolved-vite-output-dirs (3ea3407) with main (2b8b2e8)

Open in CodSpeed

@jamesopstad
jamesopstad force-pushed the resolved-vite-output-dirs branch from 24d8d29 to 3ea3407 Compare September 23, 2026 16:37
@jamesopstad
jamesopstad marked this pull request as ready for review September 23, 2026 16:59
@jamesopstad
jamesopstad changed the base branch from main to next September 24, 2026 09:29
@jamesopstad
jamesopstad force-pushed the resolved-vite-output-dirs branch from 3ea3407 to 579ed25 Compare September 24, 2026 09:29
@ematipico ematipico added the pr: astro-review Triggers a bot to do an automated review label Sep 24, 2026
@astro-factory astro-factory Bot removed the pr: astro-review Triggers a bot to do an automated review label Sep 24, 2026

@astro-factory astro-factory Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes Astro to treat Vite’s resolved outDir values as the canonical output directories during build. The implementation threads a new outputDirectories object through the build pipeline, uses it for asset generation, prerender output, SSR manifest paths, and build hooks, and defers .vite manifest cleanup until after all buildApp hooks run so platform plugins can consume the manifests. Custom prerenderer factories now receive those resolved directories via a new context argument.

Static review found the changes coherent and well-scoped:

  • StaticBuildOptions is cleanly split into pre-resolution input and post-resolution options.
  • getResolvedOutputDirectories reads the final environment configs from the Vite builder after buildApp() completes.
  • Plugin handlers that previously hard-coded settings.config.build.* now pull this.environment.config.build.outDir or use the resolved directories.
  • The new integration test exercises a Vite plugin mutating environment outDirs and asserts that hooks, the SSR manifest, and custom prerenderers all see the resolved values while the Astro config remains unchanged.
  • Existing unit tests for getOutFolder, generate.test.ts, and the incremental-build cache paths were updated to match the new resolved-directory behavior.
  • Two changesets cover both behavioral changes (minor for resolved directories / prerenderer context, patch for deferred manifest cleanup).

No correctness, security, runtime portability, or repository-policy issues were identified in the reviewed scope. The change appears ready to merge based on static review alone.

This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.

@matthewp matthewp changed the title Treat Vite's resolved ourDir values as the source of truth for build output Treat Vite's resolved outDir values as the source of truth for build output Sep 24, 2026
@ematipico
ematipico changed the base branch from next to main September 24, 2026 15:04
@ematipico
ematipico changed the base branch from main to next September 25, 2026 12:02
@ematipico
ematipico merged commit c68d737 into withastro:next Sep 25, 2026
23 of 25 checks passed
matthewp added a commit that referenced this pull request Oct 14, 2026
…build output (#18112) (#18313)

Backport of #18112 from next to main.

Generated assets, build hook `dir` values, and SSR manifest paths use the
resolved client, server, and prerender environment outDirs. Custom
prerenderer factories receive these via a new context argument. Vite
manifest cleanup is deferred until all buildApp hooks complete.

(cherry picked from commit c68d737)

Co-authored-by: James Opstad <[email protected]>
Co-authored-by: ematipico <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants