Why 为什么要用Electron Forge

An overview of Forge and its role in shipping Electron apps.Forge及其在运输Electron应用程序中的作用概述。

Motivation动机

Application packaging and distribution has always been handled outside of the core Electron framework. 应用程序的打包和分发一直在核心Electron框架之外进行。In Electron's early days as a part of the Atom editor, it was common for app developers to prepare their application for distribution by manually editing the Electron binary.在Electron作为Atom编辑器的早期,应用程序开发人员通常通过手动编辑Electron二进制文件来准备应用程序以供分发。

Since then, the Electron community has developed a rich ecosystem of tools to handle every task for Electron app distribution, including:从那时起,Electron社区开发了一个丰富的工具生态系统来处理Electron应用程序分发的每一项任务,包括:

Although these single-purpose packages are mature and production-ready, application developers need to understand what each one does and write their own scripts to glue the packages together into a build pipeline. 尽管这些单一用途的软件包已经成熟并可用于生产,但应用程序开发人员需要了解每个软件包的功能,并编写自己的脚本,将这些软件包粘合到一个构建管道中。This process requires research and iteration, and can be confusing for folks who are new to Electron.这个过程需要研究和迭代,对于刚接触Electron的人来说可能会感到困惑。

Value proposition值主张

Electron Forge is an all-in-one solution that unifies this fractured ecosystem. Electron Forge是一个一体化的解决方案,它将这个支离破碎的生态系统一致性起来。With Forge, you can create a build pipeline that brings your app from development to distribution with minimal configuration.使用Forge,您可以创建一个构建管道,用最少的配置将您的应用程序从开发到分发。

Forge is also built with advanced use cases in mind—you can add any build logic you need with custom plugins, makers or publishers. Forge的构建也考虑到了高级用例。您可以通过自定义插件、制造商或发布者添加任何需要的构建逻辑。For more details, see the Extending Electron Forge section of the docs.有关更多详细信息,请参阅文档的扩展Electron Forge部分。

Forge vs. Builder

Electron Forge can be considered an alternative to Electron Builder, which fulfills the same use-case for application building and publishing.Electron Forge可以被认为是Electron Builder的替代品,后者在应用程序构建和发布方面实现了相同的用例。

The key difference in philosophy between the two projects is that Electron Forge focuses on combining existing first-party tools into a single build pipeline, while Builder rewrites its own in-house logic for most build tasks.这两个项目在理念上的关键区别在于,Electron Forge专注于将现有的第一方工具组合成一个单一的构建管道,而Builder则为大多数构建任务重写自己的内部逻辑。

We believe there are two main advantages to using Forge:我们认为使用Forge有两个主要优势:

  1. Forge receives new features for application building as soon as they are supported in Electron一旦在Electron中得到支持,Forge就获得了应用程序构建的新功能 (e.g. ASAR integrity or universal macOS builds). (例如ASAR完整性通用macOS构建)。These features are built with first-party Electron tooling in mind, so Forge receives them as soon as they are released.这些功能是在考虑到第一方Electron工具的情况下构建的,因此Forge在发布后立即收到它们。
  2. Forge's multi-package architecture makes it easier to understand and extend.Forge的多包体系结构使其更易于理解和扩展。 Since Forge is made up of many smaller packages with clear responsibilities, it is easier to follow the flow of the code. 由于Forge由许多职责明确的较小包组成,因此更容易遵循代码流。Also, its extensible API design means that you can write your own build logic separate from the provided configuration options for advanced use cases.此外,它的可扩展API设计意味着您可以编写自己的构建逻辑,而不必为高级用例提供配置选项。