alex8088 / electron-vite-boilerplate

Comprehensive and security Electron template (TypeScript + Vue3 + Vite).
https://electron-vite.org
141 stars 25 forks source link

记一次打包之后,找不到 node_modules/../src/index.js 文件 #2

Closed Amaoc closed 2 years ago

Amaoc commented 2 years ago

在新增了 mqtt 的包之后,开发过程中一切顺利,打包之后,直接报错:‘找不到 node_modules/debug/src/index.js 文件’

解压打包之后的 app.asar 文件后,查看里面的 node_modules/debug 文件夹,发现里面除了 package.json 和 LICENSE 文件外,都是空的,对比本地的 node_modules/debug 文件,少了 src 文件夹。

瞬间懵了:包打进去了,但是没有源代码?什么情况???第一次碰到这种情况,npm, yarn, pnpm 都用过,还是不行,纠结一天后,发现了问题的原因,定位到了是 electron-builder 的配置问题,一脸尴尬...

node_modules/debug/src 中了 electron-builder.yml 中 files 的 '!*/src/' 配置,被忽略了。虽然知道这个是为了减少包的大小,但是此配置同样也会影响到了 node_modules 里面的文件,把此配置改为 '!src/*' 即可。。。

望作者改进。。。

alex8088 commented 2 years ago

good job