diff --git a/.changeset/good-humans-sniff.md b/.changeset/good-humans-sniff.md
new file mode 100644
index 000000000..d5174e271
--- /dev/null
+++ b/.changeset/good-humans-sniff.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Include server CSS in the SSR manifest assets
diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts
index 8c821f608..f7e730115 100644
--- a/packages/astro/src/core/build/vite-plugin-ssr.ts
+++ b/packages/astro/src/core/build/vite-plugin-ssr.ts
@@ -69,11 +69,18 @@ if(_start in adapter) {
return void 0;
},
async generateBundle(_opts, bundle) {
- const staticFiles = await glob('**/*', {
+ const staticFiles = new Set(await glob('**/*', {
cwd: fileURLToPath(buildOpts.buildConfig.client),
- });
+ }));
- const manifest = buildManifest(buildOpts, internals, staticFiles);
+ // Add assets from this SSR chunk as well.
+ for(const [_chunkName, chunk] of Object.entries(bundle)) {
+ if(chunk.type === 'asset') {
+ staticFiles.add(chunk.fileName);
+ }
+ }
+
+ const manifest = buildManifest(buildOpts, internals, Array.from(staticFiles));
await runHookBuildSsr({ config: buildOpts.astroConfig, manifest });
for (const [_chunkName, chunk] of Object.entries(bundle)) {
diff --git a/packages/astro/test/fixtures/ssr-assets/src/pages/index.astro b/packages/astro/test/fixtures/ssr-assets/src/pages/index.astro
new file mode 100644
index 000000000..d67c24621
--- /dev/null
+++ b/packages/astro/test/fixtures/ssr-assets/src/pages/index.astro
@@ -0,0 +1,19 @@
+---
+
+---
+
+
+
+
+ Astro
+
+
+
+ Astro
+
+
+
diff --git a/packages/astro/test/ssr-assets.test.js b/packages/astro/test/ssr-assets.test.js
new file mode 100644
index 000000000..ca62fbd88
--- /dev/null
+++ b/packages/astro/test/ssr-assets.test.js
@@ -0,0 +1,27 @@
+import { expect } from 'chai';
+import { loadFixture } from './test-utils.js';
+import testAdapter from './test-adapter.js';
+
+describe('SSR Assets', () => {
+ /** @type {import('./test-utils').Fixture} */
+ let fixture;
+
+ before(async () => {
+ fixture = await loadFixture({
+ root: './fixtures/ssr-assets/',
+ experimental: {
+ ssr: true,
+ },
+ adapter: testAdapter(),
+ });
+ await fixture.build();
+ });
+
+ it('Do not have to implement getStaticPaths', async () => {
+ const app = await fixture.loadTestAdapterApp();
+ /** @type {Set} */
+ const assets = app.manifest.assets;
+ expect(assets.size).to.equal(1);
+ expect(Array.from(assets)[0].endsWith('.css')).to.be.true;
+ });
+});
diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js
index c6c641f0d..1e6ec60f1 100644
--- a/packages/astro/test/test-utils.js
+++ b/packages/astro/test/test-utils.js
@@ -137,8 +137,10 @@ export async function loadFixture(inlineConfig) {
clean: () => fs.promises.rm(config.outDir, { maxRetries: 10, recursive: true, force: true }),
loadTestAdapterApp: async () => {
const url = new URL('./server/entry.mjs', config.outDir);
- const { createApp } = await import(url);
- return createApp();
+ const { createApp, manifest } = await import(url);
+ const app =createApp();
+ app.manifest = manifest;
+ return app;
},
editFile: async (filePath, newContents) => {
const fileUrl = new URL(filePath.replace(/^\//, ''), config.root);