我有一个要分发的Electron
和Anguarjs CLI
应用程序。
运行ng build --prod
后,我得到的dist
目录为〜1Mb。
但是,运行electron-packager .
后,该应用程序约为350Mb。
我的 Electron main.js
设置指向index.html
的dist
,但是我猜测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 封装的尺寸,dependencies
的package.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/