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

标签 angular electron angular-cli electron-packager

我有一个要分发的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/

相关文章:

javascript - 以 Angular 4 读取和写入文件

Angular - 如何将多个 "valueChanges"observables 合并为一个

javascript - Electron:项目在启动脚本时失败

javascript - Electron,如何在没有nodeIntegration的情况下访问 Node API

Angular 5 - 使用带有 uglify 和 minify 的 ng build 开发/QA 构建(如 ng build --prod)

angular - 使用 rxjs 进行垫排序无法正常工作

Angular-CLI 在项目库中创建组件

javascript - Electron 图像的异步缩放

javascript - 模块构建失败 : TypeError: Cannot read property 'newLine' of undefined

angular-cli - 使用 ng build 在 Angular 库中构建外部 JS(不是 TS)文件?