Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

chore(build): clear stale frontend export before next build (#4675)

Louis Beaumontaf9f0ec8f0e2
diff --git a/apps/screenpipe-app-tauri/scripts/pre_build.js b/apps/screenpipe-app-tauri/scripts/pre_build.js
index 89ba84b9e..1bf727dac 100644
--- a/apps/screenpipe-app-tauri/scripts/pre_build.js
+++ b/apps/screenpipe-app-tauri/scripts/pre_build.js
@@ -23,6 +23,16 @@ const winArch = platform === 'windows' ? (process.arch === 'arm64' ? 'arm64' : '
const cwd = process.cwd()
console.log('cwd', cwd)
+// Remove any stale static export before the frontend rebuilds. `next build`
+// (output: 'export') only writes ../out on success; if it fails (e.g. a type
+// error), a previously-built out/ stays on disk and tauri embeds that OLD
+// bundle — so the app "builds" but silently ships a stale UI. Clearing it here
+// (prebuild runs before `next build`) means a failed build leaves no out/ and
+// tauri fails loudly on the missing frontendDist instead. See #4645 post-mortem.
+const staleExportDir = path.join(cwd, '..', 'out')
+await fs.rm(staleExportDir, { recursive: true, force: true })
+console.log('cleared stale frontend export:', staleExportDir)
+
const config = {
ffmpegRealname: 'ffmpeg',