Describe the bug
I am using electron-vite for the electron platform which builds the application to the build folder with respective folders for main, preload and renderer. And I am using capacitor.config.ts which is not automatically included in build folder by electron-vite so I use tsc to compile it to that folder, as this file is required by capacitor-sqlite plugin.
But even after doing all of this I get an error when running with electron-vite dev that
Error: Could not dynamically require "path\to\electron\build\capacitor.config.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
build the electron main process successfully
-----
"__require" is not exported by "build/capacitor.config.js", imported by "commonjs-dynamic-modules".
file: commonjs-dynamic-modules:1:9
1: import { __require as require0 } from "...\\electron\\build\\capacitor.c...
^
2:
3: var dynamicModules;
Expected behavior
It should compile and run successfully and resolve capacitor.config.js file
Desktop (please complete the following information):
Describe the bug I am using electron-vite for the electron platform which builds the application to the
build
folder with respective folders for main, preload and renderer. And I am usingcapacitor.config.ts
which is not automatically included in build folder by electron-vite so I usetsc
to compile it to that folder, as this file is required by capacitor-sqlite plugin.But even after doing all of this I get an error when running with electron-vite dev that
Error: Could not dynamically require "path\to\electron\build\capacitor.config.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
So I added this to electron.vite.config.ts
commonjsOptions: { dynamicRequireTargets: ["build/capacitor.config.js"], },
Now electron.vite.config.ts file looks like this
Now this below error pops up.
Expected behavior It should compile and run successfully and resolve capacitor.config.js file
Desktop (please complete the following information):