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.
This commit is contained in:
Mary Kate Fain
2026-03-27 16:59:24 -05:00
parent d4a928b682
commit 81e42f24c8
+3
View File
@@ -150,6 +150,9 @@ export default defineConfig(() => {
build: {
target: 'esnext',
},
optimizeDeps: {
exclude: ['@capacitor/filesystem', '@capacitor/share'],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),