Open PDKSophia opened 1 year ago
ai, but...
For those using vite-plugin-electron
in their vite.config.ts
Note: I assume that you aren't using ffmpeg in your preload script. If you do, just copy over the vite
property from the main entrypoint section.
import { defineConfig } from 'vite';
import electron from 'vite-plugin-electron';
export default defineConfig({
plugins: [
electron([
{
entry: "src/electron/node/main.ts", // wherever your main entrypoint
vite: {
build: {
rollupOptions: {
plugins: [
alias({
entries: [
{
find: "./lib-cov/fluent-ffmpeg",
replacement: "./lib/fluent-ffmpeg",
},
],
}),
],
},
},
},
},
{
entry: "src/electron/node/preload.ts", // wherever your preload entrypoint
onstart(options) {
// Notify the Renderer-Process to reload the page when the Preload-Scripts build is complete,
// instead of restarting the entire Electron App.
options.reload();
},
},
]),
]
});
I also have the same problem. According to everyone's solutions, I have not solved it.
I use
React+Vite+Electron
. I will share some of my knowledgewhen i downloaded
fluent-ffmpeg
,i want to import it,but i got errorthen i went to the
node_modules/fluent-ffmpeg
folder to see its source code,theprocess.env.FLUENTFFMPEG_COV
may be an error value.in vite docs , we can be configured through the
define
attribute, so i go to configure valueAnd added two lines of code to the source code, print
process.env.FLUENTFFMPEG_COV
valuewe expect it to be a
boolean
, but it's actually astring
!!!try again, this time we change it to
undefined
, same result !No matter what value is configured, it is of
string type
and will meet the condition of true, so i try to configure as anempty string
Error , I don't know why, so hard !
The solution is to copy the
fluent-ffmpeg folder
, change the source code, but this is not what I expected !when i'm depressed, i was surprised to find that the
vite startup electron plugin
I wrote can inject environment variables, below is my code:this way solved my problem !
Originally posted by @PDKSophia in https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/573#issuecomment-1578026754