Skip to content

Commit

Permalink
fix: remove the .vite-ssg-temp folder before and after a build (#424)
Browse files Browse the repository at this point in the history
Remove the .vite-ssg-temp folder before and after a build, instead of removing just the randomly generated subfolder.
  • Loading branch information
HummingMind authored Nov 1, 2024
1 parent 7142389 commit babc6c2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig

const cwd = process.cwd()
const root = config.root || cwd
const ssgOut = join(root, '.vite-ssg-temp', Math.random().toString(36).substring(2, 12))
const ssgOutTempFolder = join(root, '.vite-ssg-temp')
const ssgOut = join(ssgOutTempFolder, Math.random().toString(36).substring(2, 12))
const outDir = config.build.outDir || 'dist'
const out = isAbsolute(outDir) ? outDir : join(root, outDir)

Expand All @@ -58,8 +59,8 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig

const beastiesOptions = mergedOptions.beastiesOptions ?? mergedOptions.crittersOptions ?? {}

if (fs.existsSync(ssgOut))
await fs.remove(ssgOut)
if (fs.existsSync(ssgOutTempFolder))
await fs.remove(ssgOutTempFolder)

// client
buildLog('Build for client...')
Expand Down Expand Up @@ -219,7 +220,7 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig

await queue.start().onIdle()

await fs.remove(ssgOut)
await fs.remove(ssgOutTempFolder)

// when `vite-plugin-pwa` is presented, use it to regenerate SW after rendering
const pwaPlugin: VitePluginPWAAPI = config.plugins.find(i => i.name === 'vite-plugin-pwa')?.api
Expand Down

0 comments on commit babc6c2

Please sign in to comment.