gpt4 book ai didi

angular - Electron + Angular CLI如何使用 Electron 打包程序打包dist

转载 作者:行者123 更新时间:2023-12-03 12:22:32 28 4
gpt4 key购买 nike

我有一个要分发的ElectronAnguarjs CLI应用程序。

运行ng build --prod后,我得到的dist目录为〜1Mb。
但是,运行electron-packager .后,该应用程序约为350Mb。

我的 Electron main.js设置指向index.htmldist,但是我猜测package命令不会使用dist来构建应用程序,而是使用肿的dev版本。
我尝试从electron-packager .中运行dist,它仍然会创建一个巨大的应用程序。

有没有办法打包dist文件夹?
我是否应该使用其他 package 工具?

我的目的是 package 应用程序,以免分配带宽。

最佳答案

electron-packager readme.md:

Be careful not to include node_modules you don't want into your final app. If you put them in the devDependencies section of package.json, by default none of the modules related to those dependencies will be copied in the app bundles.



Angular 式CLI在内部使用 webpack来 bundle 您的代码。为了减小 Electron 封装的尺寸, dependenciespackage.json部分中当前由webpack bundle 的任何物品都可以放在 devDependencies部分中。这样可以防止 electron-packager bundle 您实际上没有引用的 node_modules代码,这是因为webpack在将 dist文件夹中的输出块 bundle 时已经提取了它。

关于angular - Electron + Angular CLI如何使用 Electron 打包程序打包dist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49072226/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com