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

关于 dist-electron 其它js文件路径问题 #152

Closed
Canees opened this issue Aug 15, 2023 · 16 comments
Closed

关于 dist-electron 其它js文件路径问题 #152

Canees opened this issue Aug 15, 2023 · 16 comments

Comments

@Canees
Copy link

Canees commented Aug 15, 2023

问题点:

  1. 如果electron 中包含了其它js脚本,路径使用的是join(__dirname, './***') 此时dist-electron中又不存在js脚本就会出错,得改路径才能解决
  2. 如果package.json的入口文件设置为electron/main.js,,vite.config中设置electron的entry同样为electron/main.js 程序都能正常更新

总结:此时dist-electron感觉就没啥存在必要

@sky124380729
Copy link

遇到了同样的问题

@shuyuTech
Copy link

不清楚你的使用方式,但是可以用如下解决

import.meta.globEager("../xx/*.js");

@sky124380729
Copy link

不清楚你的使用方式,但是可以用如下解决

import.meta.globEager("../xx/*.js");

哪里配?

@shuyuTech
Copy link

不清楚你的使用方式,但是可以用如下解决

import.meta.globEager("../xx/*.js");

哪里配?

😮,vite基本用法,哪里用,哪里配。https://cn.vitejs.dev/guide/features.html#glob-import

@caoxiemeihao
Copy link
Member

不清楚你的使用方式,但是可以用如下解决

import.meta.globEager("../xx/*.js");

正解 👍

@Canees
Copy link
Author

Canees commented Aug 21, 2023

狮子的使用方式,但是可以用以下解决

import.meta.globEager("../xx/*.js");

我说的是electron主进程的js文件,不是vite
image
image
image

我这样配置,跟它自动生成的dist-electron没一点关系。

@caoxiemeihao
Copy link
Member

caoxiemeihao commented Aug 21, 2023

你可以考虑用 vite-plugin-static-copyicon 目录 copy 到 dist-electron 或者直接把 icon 放到 electron 目录外面使用。

其次 import.meta.globEager 在主进程中也可使用。

@Canees
Copy link
Author

Canees commented Aug 21, 2023

没必要多装啥插件,eletron的主文件图标等都需要在主进程使用,就单纯觉得多生成的dist-electron 没啥用。
image
看了源码,修改配置到dist里面去,不影响electron打包

@sky124380729
Copy link

没必要多装啥插件,eletron的主文件图标等都需要在主进程使用,就单纯觉得多生成的dist-electron 没啥用。 image 看了源码,修改配置到dist里面去,不影响electron打包

我换了vite-electron-plugin

@Canees
Copy link
Author

Canees commented Aug 21, 2023

没必要多装啥插件,eletron的主文件图标等都需要在主进程使用,就单纯觉得多生成的dist-electron 没啥用。 image 看了源码,修改配置到dist里面去,不影响electron打包

我换了vite-electron-plugin

咋样嘛?我看都是同一个人写的

@sky124380729
Copy link

没必要多装啥插件,eletron的主文件图标等都需要在主进程使用,就单纯觉得多生成的dist-electron 没啥用。 image 看了源码,修改配置到dist里面去,不影响electron打包

我换了vite-electron-plugin

咋样嘛?我看都是同一个人写的

作者不就在楼上嘛。我也不知道他为啥整两个,反正入口文件多的问题我暂时使用vite-electron-plugin了,我也看了作者知乎的文章 一个插件将 Vite 与 Electron 无缝结合,后面考虑自己写一个

@caoxiemeihao
Copy link
Member

去看置顶的 ISSUE
关于 vite-plugin-electron 与 vite-electron-plugin

@Canees
Copy link
Author

Canees commented Aug 21, 2023

没必要多装啥插件,eletron的主文件图标等都需要在主进程使用,就单纯觉得多生成的dist-electron 没啥用。 image 看了源码,修改配置到dist里面去,不影响electron打包

我换了vite-electron-plugin

咋样嘛?我看都是同一个人写的

作者不就在楼上嘛。我也不知道他为啥整两个,反正入口文件多的问题我暂时使用vite-electron-plugin了,我也看了作者知乎的文章 一个插件将 Vite 与 Electron 无缝结合,后面考虑自己写一个

作者说了构建方式不同。-plugin 启动速度明显超过-electron

@sky124380729
Copy link

去看置顶的 ISSUE 关于 vite-plugin-electron 与 vite-electron-plugin

很棒的作者

@Canees
Copy link
Author

Canees commented Aug 21, 2023

好家伙,-plugin 中引用了-electron 😀

@caoxiemeihao
Copy link
Member

caoxiemeihao commented Aug 22, 2023

之前这两个插件共存了很久
vite-plugin-electron 用于 electron-vite-vue
vite-electron-plugin 用于 electron-vite-react

后来我加入 Electron 后需要给 electron-forge 提交 Vite 支持部分代码,内部商量了几波后最终确定使用 vite-plugin-electron 作为原型给 electron-forge 贡献代码。
然后 vite-electron-plugin 就被我转移到了我的私人名下不再继续维护,不过它有着极其出色的性能还是让我念念不忘!

于是乎在最新的 vite-plugin-electron@0.13.0-beta.2 中加了一个 Not Bundle 功能,这样一来性能似乎接近 vite-electron-plugin 很多,甚至 patak-dev 也很喜欢这个方案。

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants