diff --git a/.changeset/bright-elephants-yell.md b/.changeset/bright-elephants-yell.md new file mode 100644 index 0000000000..9b4e71c8ae --- /dev/null +++ b/.changeset/bright-elephants-yell.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a regression for `getViteConfig`, where the inline config wasn't merged in the final config. diff --git a/packages/astro/src/config/index.ts b/packages/astro/src/config/index.ts index aa078a9482..ee4df1c3d1 100644 --- a/packages/astro/src/config/index.ts +++ b/packages/astro/src/config/index.ts @@ -1,4 +1,4 @@ -import type { UserConfig } from 'vite'; +import type { UserConfig as ViteUserConfig } from 'vite'; import type { AstroInlineConfig, AstroUserConfig } from '../@types/astro.js'; import { Logger } from '../core/logger/core.js'; @@ -6,7 +6,7 @@ export function defineConfig(config: AstroUserConfig) { return config; } -export function getViteConfig(inlineConfig: UserConfig, inlineAstroConfig: AstroInlineConfig = {}) { +export function getViteConfig(userViteConfig: ViteUserConfig, inlineAstroConfig: AstroInlineConfig = {}) { // Return an async Vite config getter which exposes a resolved `mode` and `command` return async ({ mode, command }: { mode: string; command: 'serve' | 'build' }) => { // Vite `command` is `serve | build`, but Astro uses `dev | build` @@ -34,8 +34,8 @@ export function getViteConfig(inlineConfig: UserConfig, inlineAstroConfig: Astro dest: nodeLogDestination, level: 'info', }); - const { astroConfig: config, userConfig } = await resolveConfig(inlineAstroConfig, cmd); - let settings = await createSettings(config, inlineConfig.root); + const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd); + let settings = await createSettings(config, userViteConfig.root); settings = await runHookConfigSetup({ settings, command: cmd, logger }); const viteConfig = await createVite( { @@ -48,6 +48,6 @@ export function getViteConfig(inlineConfig: UserConfig, inlineAstroConfig: Astro { settings, logger, mode } ); await runHookConfigDone({ settings, logger }); - return mergeConfig(viteConfig, userConfig); + return mergeConfig(viteConfig, userViteConfig); }; }