node-font-list icon indicating copy to clipboard operation
node-font-list copied to clipboard

Support electron-builder in mac

Open wxfred opened this issue 4 years ago • 4 comments

__dirname has different meaning in electron-builder, in font-list/libs/darwin/index.js const bin = path.join(__dirname, 'fontlist') can't get the correct path of the fontlist file. Is there any solution?

wxfred avatar Apr 19 '21 06:04 wxfred

Do you have more information? My project is also packaged using electron-builder, and everything seems to go well.

oldj avatar Apr 19 '21 11:04 oldj

@oldj 我使用的是vue-cli-plugin-electron-builder,mac下electron调试,代码会被临时打包在项目的dist_electron目录 我查看了font-list的源码,mac打包会调用darwin/index.js,文件中使用了__dirname,该变量直接被解析成了dist_electron/,导致无法访问到fontlist.m脚本

wxfred avatar Jul 01 '21 06:07 wxfred

@oldj webpack配置__dirname保持文件原始路径而不是打包后文件路径

config.node
  .set('__dirname', true)

electron调试模式可以正确获取到脚本文件

但是,electron打包成dmg安装后,直接白屏

我又测试了一下不修改webpack配置直接打包dmg,能够访问vue页面,但是获取不到字体信息,应该还是脚本路径的问题

wxfred avatar Jul 01 '21 13:07 wxfred

see #29

Beats0 avatar Mar 22 '22 03:03 Beats0