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] 开发环境读public下的文件可以展示,打包后找不到文件 #498

Open
chaoyang915506 opened this issue Jun 25, 2024 · 11 comments
Labels
help wanted Extra attention is needed

Comments

@chaoyang915506
Copy link

小白刚开始用electron
在开发环境使用public文件下的文件页面可以展示
image
打包成win版本后路径就错误了,图片无法加载出来
image
请问我是缺少哪些配置吗。

@chaoyang915506 chaoyang915506 added the help wanted Extra attention is needed label Jun 25, 2024
@RSS1102
Copy link
Member

RSS1102 commented Jun 25, 2024

请提供依赖版本,或者最小代码复现。

@chaoyang915506
Copy link
Author

chaoyang915506 commented Jun 25, 2024

"version": "28.1.0"
image
image

@RSS1102
Copy link
Member

RSS1102 commented Jun 25, 2024

请提供一个复现的代码连接。截图看不出来。

@chaoyang915506
Copy link
Author

@RSS1102
Copy link
Member

RSS1102 commented Jun 28, 2024

image
image

@RSS1102
Copy link
Member

RSS1102 commented Jun 28, 2024

node -v
v18.16.0

@chaoyang915506
Copy link
Author

image
image
我这还是打包后无法展示
我的流程是
npm install
npm run dev 开发环境没问题
npm run build:win release 下打开 28.1.0下的xin-uppacked的exe无法展示图片

@RSS1102
Copy link
Member

RSS1102 commented Jul 1, 2024

兄弟尝试一下这个api assetsinclude

export default defineConfig({
  assetsInclude: ['**/*.png'],
})

image

@chaoyang915506
Copy link
Author

也不好使,唯一好使的只能是import 图片 from 地址。

@speauty
Copy link

speauty commented Aug 15, 2024

我也遇到这个问题了,之前用nsis的时候,还可以直接复制一些目录进去,不知道electron那个可以操作不

@Sailwayfun
Copy link

Sailwayfun commented Oct 29, 2024

我有遇到類似問題,好像是路徑寫在變數中會解析不完整。最後是在main process fork 一個 express server,讓生產環境跑在 http 上面,算是個 work around
https://github.com/Sailwayfun/electron-vue-test

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

4 participants