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:
@@ -150,6 +150,9 @@ export default defineConfig(() => {
|
||||
build: {
|
||||
target: 'esnext',
|
||||
},
|
||||
optimizeDeps: {
|
||||
exclude: ['@capacitor/filesystem', '@capacitor/share'],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
|
||||
Reference in New Issue
Block a user