@@ -107,8 +107,9 @@ export async function viteBuild(opts: StaticBuildOptions) {
107
107
const ssrOutputs = viteBuildReturnToRollupOutputs ( ssrOutput ) ;
108
108
const clientOutputs = viteBuildReturnToRollupOutputs ( clientOutput ?? [ ] ) ;
109
109
await runPostBuildHooks ( container , ssrOutputs , clientOutputs ) ;
110
+ let contentFileNames : string [ ] | undefined = undefined ;
110
111
if ( opts . settings . config . experimental . contentCollectionCache ) {
111
- await copyContentToCache ( opts ) ;
112
+ contentFileNames = await copyContentToCache ( opts ) ;
112
113
}
113
114
settings . timer . end ( 'Client build' ) ;
114
115
@@ -129,20 +130,21 @@ export async function viteBuild(opts: StaticBuildOptions) {
129
130
}
130
131
}
131
132
132
- return { internals, ssrOutputChunkNames } ;
133
+ return { internals, ssrOutputChunkNames, contentFileNames } ;
133
134
}
134
135
135
136
export async function staticBuild (
136
137
opts : StaticBuildOptions ,
137
138
internals : BuildInternals ,
138
- ssrOutputChunkNames : string [ ]
139
+ ssrOutputChunkNames : string [ ] ,
140
+ contentFileNames ?: string [ ]
139
141
) {
140
142
const { settings } = opts ;
141
143
switch ( true ) {
142
144
case settings . config . output === 'static' : {
143
145
settings . timer . start ( 'Static generate' ) ;
144
146
await generatePages ( opts , internals ) ;
145
- await cleanServerOutput ( opts , ssrOutputChunkNames , internals ) ;
147
+ await cleanServerOutput ( opts , ssrOutputChunkNames , contentFileNames , internals ) ;
146
148
settings . timer . end ( 'Static generate' ) ;
147
149
return ;
148
150
}
@@ -431,11 +433,13 @@ async function cleanStaticOutput(
431
433
async function cleanServerOutput (
432
434
opts : StaticBuildOptions ,
433
435
ssrOutputChunkNames : string [ ] ,
436
+ contentFileNames : string [ ] | undefined ,
434
437
internals : BuildInternals
435
438
) {
436
439
const out = getOutDirWithinCwd ( opts . settings . config . outDir ) ;
437
440
// The SSR output chunks for Astro are all .mjs files
438
- const files = ssrOutputChunkNames . filter ( ( f ) => f . endsWith ( '.mjs' ) ) ;
441
+ const files = ssrOutputChunkNames . filter ( ( f ) => f . endsWith ( '.mjs' ) )
442
+ . concat ( contentFileNames ?? [ ] ) ;
439
443
if ( internals . manifestFileName ) {
440
444
files . push ( internals . manifestFileName ) ;
441
445
}
0 commit comments