diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index 309e01967de9..4e313589353b 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -218,6 +218,7 @@ async function buildEnvironments(opts: StaticBuildOptions, internals: BuildInter output: { entryFileNames: `${PRERENDER_ENTRY_FILENAME_PREFIX}.[hash].mjs`, format: 'esm', + ...viteConfig.environments?.prerender?.build?.rollupOptions?.output, }, }, ssr: true, @@ -245,6 +246,11 @@ async function buildEnvironments(opts: StaticBuildOptions, internals: BuildInter ssr: { build: { outDir: fileURLToPath(getServerOutputDirectory(settings)), + rollupOptions: { + output: { + ...viteConfig.environments?.ssr?.build?.rollupOptions?.output + } + } }, }, }, diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js index 92aa6db80252..0172e93b187c 100644 --- a/packages/astro/test/astro-css-bundling.test.js +++ b/packages/astro/test/astro-css-bundling.test.js @@ -80,17 +80,23 @@ describe('CSS Bundling', function () { root: './fixtures/astro-css-bundling/', // test suite was authored when inlineStylesheets defaulted to never - build: { inlineStylesheets: 'never' }, + build: { + inlineStylesheets: 'never', + assets: 'assets', + }, vite: { - build: { - rollupOptions: { - output: { - assetFileNames: 'assets/[name][extname]', - entryFileNames: '[name].js', - }, - }, - }, + environments: { + prerender: { + build: { + rollupOptions: { + output: { + assetFileNames: 'assets/[name][extname]', + } + } + } + } + } }, }); await fixture.build({ mode: 'production' }); @@ -106,10 +112,9 @@ describe('CSS Bundling', function () { assert.doesNotMatch(firstFound, /[a-z]+\.[\da-z]{8}\.css/); }); - it('there are 2 index named CSS files', async () => { + it('there are 4 css files (3 pages, one shared component)', async () => { const dir = await fixture.readdir('/assets'); - const indexNamedFiles = dir.filter((name) => name.startsWith('index')); - assert.equal(indexNamedFiles.length, 2); + assert.equal(dir.length, 4); }); }); });