electron-vite-vue
electron-vite-vue copied to clipboard
[Help] how to include additional files in dist?
I have a script that is forked in the main process, how can I include this in the dist build?
γvite-plugin-static-copy - npmγhttps://www.npmjs.com/package/vite-plugin-static-copy
Sorry it is a typescript file not a static file.
You may need additional build typescript files. This is not the default feature.
I'm also looking into doing something similar, but with a python (during dev) and exe for (during build, via pyinstaller). I have attempted to use the linked (https://www.npmjs.com/package/vite-plugin-static-copy) but couldn't get it to work on Windows. File detected but doesn't seems to be copied over from root/py to /dist/py
How can we use files
, extraresources
or extraFiles
ya? I'm really new to electron, sorry for newbie questions
Sharing my setup here, which unfortunately is not working. I am working on Windows.
@jinusean , sorry for cluttering your issues/help wanted, wanted to avoid duplication of issues raised. Do let me know if I need to move this elsewhere.
May be electron-builder Application Contents useful.
I found out what I did wrong. For those who is here looking for something similar functionality:
- Just copy whatever folder that you wanted in the
public
folder, it would be copied over automatically duringvite build
- Similarly, the
https://www.npmjs.com/package/vite-plugin-static-copy
also works, just make sure you are runningvite build
first. - During
npm run dev
, you just need to check whetherbuild
orpublic
viaprocess.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, "../public");
, and handle it accordingly.
Thanks @caoxiemeihao for the helps!
@Hafiidz thank you!
Now, a new plugin is available π vite-electron-plugin
βββ¬ dist-electron // Automatically generated from the electron directory
β βββ main.js
β
βββ static // static files here
β
βββ¬ electron // The Electron source codes directory
β βββ main.ts
β
βββ¬ src
β βββ main.ts
β βββ style.css
β βββ vite-env.d.ts
β
βββ index.html
βββ package.json
βββ tsconfig.json
βββ vite.config.ts