Skip to content

Commit 4987d6f

Browse files
authored
Handle custom injected entry files during build (#5499)
1 parent 0d09747 commit 4987d6f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/kind-seahorses-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Handle custom injected entry files during build

packages/astro/src/core/build/static-build.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
1515
import { isModeServerWithNoAdapter } from '../../core/util.js';
1616
import { runHookBuildSetup } from '../../integrations/index.js';
1717
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
18+
import { resolvedPagesVirtualModuleId } from '../app/index.js';
1819
import { AstroError, AstroErrorData } from '../errors/index.js';
1920
import { info } from '../logger/core.js';
2021
import { getOutDirWithinCwd } from './common.js';
@@ -138,7 +139,13 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
138139
chunkFileNames: `chunks/[name].[hash].mjs`,
139140
assetFileNames: `${settings.config.build.assets}/[name].[hash][extname]`,
140141
...viteConfig.build?.rollupOptions?.output,
141-
entryFileNames: opts.buildConfig.serverEntry,
142+
entryFileNames(chunkInfo) {
143+
if (chunkInfo.facadeModuleId === resolvedPagesVirtualModuleId) {
144+
return opts.buildConfig.serverEntry;
145+
} else {
146+
return '[name].mjs';
147+
}
148+
},
142149
},
143150
},
144151
ssr: true,

0 commit comments

Comments
 (0)