Skip to content

Commit

Permalink
fix(nitro): do not overwrite output files for browser-preset (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Sep 9, 2021
1 parent d60ea23 commit 69fd546
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/presets/browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFile } from 'fs-extra'
import { existsSync, writeFile } from 'fs-extra'
import { resolve } from 'upath'
import consola from 'consola'
import { extendPreset, prettyPath } from '../utils'
Expand Down Expand Up @@ -68,10 +68,15 @@ if ('serviceWorker' in navigator) {
await writeFile(resolve(output.publicDir, 'sw.js'), `self.importScripts('${input._nuxt.routerBase}_server/index.mjs');`)

// Temp fix
await writeFile(resolve(output.publicDir, 'index.html'), html)
await writeFile(resolve(output.publicDir, '200.html'), html)
await writeFile(resolve(output.publicDir, '404.html'), html)

if (!existsSync(resolve(output.publicDir, 'index.html'))) {
await writeFile(resolve(output.publicDir, 'index.html'), html)
}
if (!existsSync(resolve(output.publicDir, '200.html'))) {
await writeFile(resolve(output.publicDir, '200.html'), html)
}
if (!existsSync(resolve(output.publicDir, '404.html'))) {
await writeFile(resolve(output.publicDir, '404.html'), html)
}
consola.info('Ready to deploy to static hosting:', prettyPath(output.publicDir as string))
}
}
Expand Down

0 comments on commit 69fd546

Please sign in to comment.