Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] how to include additional files in dist? #255

Closed
jinusean opened this issue Sep 12, 2022 · 10 comments
Closed

[Help] how to include additional files in dist? #255

jinusean opened this issue Sep 12, 2022 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@jinusean
Copy link

I have a script that is forked in the main process, how can I include this in the dist build?

@jinusean jinusean added the help wanted Extra attention is needed label Sep 12, 2022
@caoxiemeihao
Copy link
Member

【vite-plugin-static-copy - npm】https://www.npmjs.com/package/vite-plugin-static-copy

@jinusean
Copy link
Author

Sorry it is a typescript file not a static file.

@caoxiemeihao
Copy link
Member

You may need additional build typescript files.
This is not the default feature.

@hafiidz
Copy link

hafiidz commented Sep 17, 2022

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

@hafiidz
Copy link

hafiidz commented Sep 17, 2022

How can we use files, extraresources or extraFiles ya? I'm really new to electron, sorry for newbie questions

@hafiidz
Copy link

hafiidz commented Sep 17, 2022

image

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.

@caoxiemeihao
Copy link
Member

May be electron-builder Application Contents useful.

@hafiidz
Copy link

hafiidz commented Sep 17, 2022

I found out what I did wrong. For those who is here looking for something similar functionality:

  1. Just copy whatever folder that you wanted in the public folder, it would be copied over automatically during vite build
  2. Similarly, the https://www.npmjs.com/package/vite-plugin-static-copy also works, just make sure you are running vite build first.
  3. During npm run dev, you just need to check whether build or public via process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, "../public");, and handle it accordingly.

Thanks @caoxiemeihao for the helps!

@jinusean
Copy link
Author

jinusean commented Sep 22, 2022

@hafiidz thank you!

@caoxiemeihao
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants