Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): computation of outDir for SSR builds #12249

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-pugs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes an issue where Astro creates an incorrect folder when `outDir` is defined, and an adapter is used.
4 changes: 2 additions & 2 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,13 +664,13 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: string) {
!config.build.server.toString().startsWith(config.outDir.toString()) &&
config.build.server.toString().endsWith('dist/server/')
) {
config.build.server = new URL('./dist/server/', config.outDir);
config.build.server = new URL('./server/', config.outDir);
}
if (
!config.build.client.toString().startsWith(config.outDir.toString()) &&
config.build.client.toString().endsWith('dist/client/')
) {
config.build.client = new URL('./dist/client/', config.outDir);
config.build.client = new URL('./client/', config.outDir);
}

// Handle `base` trailing slash based on `trailingSlash` config
Expand Down
1 change: 1 addition & 0 deletions packages/astro/test/fixtures/ssr-locals/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom-dir
31 changes: 31 additions & 0 deletions packages/astro/test/ssr-out-dir.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';

describe('The build', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
/** @type {import('./test-utils.js').App} */
let app;

Check notice on line 10 in packages/astro/test/ssr-out-dir.test.js

View workflow job for this annotation

GitHub Actions / Lint

lint/correctness/noUnusedVariables

This variable is unused.

before(async () => {
fixture = await loadFixture({
root: './fixtures/ssr-locals/',
output: 'server',
adapter: testAdapter(),
outDir: 'custom-dir',
});
await fixture.build();
app = await fixture.loadTestAdapterApp();
});

it('should output the files in `custom-dir`', async () => {
try {
await fixture.readFile('/server/entry.mjs');
assert.ok(true);
} catch (e) {
assert.fail(e);
}
});
});
Loading