Skip to content

fix(config): rewrite './' base to '/' for server environments#22520

Open
itsybitsybootsy wants to merge 1 commit into
vitejs:mainfrom
itsybitsybootsy:fix/relative-base-environment-api
Open

fix(config): rewrite './' base to '/' for server environments#22520
itsybitsybootsy wants to merge 1 commit into
vitejs:mainfrom
itsybitsybootsy:fix/relative-base-environment-api

Conversation

@itsybitsybootsy
Copy link
Copy Markdown

closes #21812

build.ssr: true rewrites base: './' to '/', but the new environment API check (consumer === 'server') doesn't, so env-API server builds use ./ as the base. import.meta.url can't handle ./ on the server.

Extended the rewrite to any environment with consumer: 'server'. Client environments still get ./ from the outer check.

toOutputFilePathWithoutRuntime still reads config.build.ssr directly. Only matters for server-side HTML/CSS emit, which doesn't happen in practice, so leaving it.

Tests in config.spec.ts cover the env-API server case, legacy build.ssr: true, client fall-through, and non-shortcut bases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting build?.ssr makes base: "./" to be treated as base: "/" but building an Environment with conumer: 'server' does not do the same

1 participant