File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,29 @@ export default defineNuxtModule<ModuleOptions>({
155155 } )
156156 )
157157
158+ if ( nuxt . options . _generate ) {
159+ nuxt . hook ( 'nitro:config' , config => {
160+ config . prerender ||= { }
161+ config . prerender . routes ||= [ ]
162+ config . prerender . routes . push ( '/200.html' )
163+ } )
164+
165+ // Ensure there is an index.html file present when doing static file generation
166+ let publicFolder : string
167+ nuxt . hook ( 'nitro:init' , nitro => {
168+ publicFolder = nitro . options . output . publicDir
169+ } )
170+
171+ nuxt . hook ( 'close' , async ( ) => {
172+ const indexFile = join ( publicFolder , 'index.html' )
173+ const fallbackFile = join ( publicFolder , '200.html' )
174+
175+ if ( ! existsSync ( indexFile ) && existsSync ( fallbackFile ) ) {
176+ await fsp . copyFile ( fallbackFile , indexFile )
177+ }
178+ } )
179+ }
180+
158181 const { setupBasic, setupCore, setupUtilities } = useCSSSetup ( )
159182
160183 // Add Ionic Core CSS
You can’t perform that action at this time.
0 commit comments