From e959698fedee4e548053e251d103eaeb9c6995cd Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 18 Feb 2026 14:13:19 +0000 Subject: [PATCH] fix(build): scope adapter build to ssr environment (#15563) * fix(build): scope adapter build to ssr environment * Update .changeset/full-carpets-hide.md Co-authored-by: Florian Lefebvre --------- Co-authored-by: Florian Lefebvre --- .changeset/full-carpets-hide.md | 5 +++++ .../src/vite-plugin-adapter-config/index.ts | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 .changeset/full-carpets-hide.md diff --git a/.changeset/full-carpets-hide.md b/.changeset/full-carpets-hide.md new file mode 100644 index 000000000000..613e35c44582 --- /dev/null +++ b/.changeset/full-carpets-hide.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where warnings would be logged during the build using one of the official adapters diff --git a/packages/astro/src/vite-plugin-adapter-config/index.ts b/packages/astro/src/vite-plugin-adapter-config/index.ts index 539186ed5246..304fb719e1a8 100644 --- a/packages/astro/src/vite-plugin-adapter-config/index.ts +++ b/packages/astro/src/vite-plugin-adapter-config/index.ts @@ -2,6 +2,7 @@ import type { Plugin as VitePlugin } from 'vite'; import { isAstroServerEnvironment } from '../environments.js'; import type { AstroSettings } from '../types/astro.js'; import { fileURLToPath } from 'node:url'; +import { ASTRO_VITE_ENVIRONMENT_NAMES } from '../core/constants.js'; // This is used by Cloudflare's optimizeDeps const VIRTUAL_CLIENT_ID = 'virtual:astro:adapter-config/client'; @@ -14,13 +15,17 @@ export function vitePluginAdapterConfig(settings: AstroSettings): VitePlugin { const { adapter } = settings; if (adapter && adapter.entrypointResolution === 'auto' && adapter.serverEntrypoint) { return { - build: { - rollupOptions: { - input: { - index: - typeof adapter.serverEntrypoint === 'string' - ? adapter.serverEntrypoint - : fileURLToPath(adapter.serverEntrypoint), + environments: { + [ASTRO_VITE_ENVIRONMENT_NAMES.ssr]: { + build: { + rollupOptions: { + input: { + index: + typeof adapter.serverEntrypoint === 'string' + ? adapter.serverEntrypoint + : fileURLToPath(adapter.serverEntrypoint), + }, + }, }, }, },