From 81e42f24c845d5cbc9c3a315517f654dce57d6f5 Mon Sep 17 00:00:00 2001 From: Mary Kate Fain Date: Fri, 27 Mar 2026 16:59:24 -0500 Subject: [PATCH] Exclude Capacitor native-only plugins from Vite dep optimization @capacitor/filesystem and @capacitor/share are dynamically imported behind a Capacitor.isNativePlatform() guard, but Vite's import analysis plugin still tries to resolve them at transform time in dev mode. This causes a 'Failed to resolve import' error when running the dev server. Excluding them from optimizeDeps prevents Vite from pre-bundling these packages, letting the dynamic imports resolve naturally at runtime. --- vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 7c54ce0e..cef0c56e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -150,6 +150,9 @@ export default defineConfig(() => { build: { target: 'esnext', }, + optimizeDeps: { + exclude: ['@capacitor/filesystem', '@capacitor/share'], + }, resolve: { alias: { "@": path.resolve(__dirname, "./src"),