简体   繁体   English

电子:电子建设者配置

[英]Electron: electron-builder config

Can somebody explain to me how electron-builder config work? 有人可以向我解释电子构建器配置是如何工作的吗? I can't understand 95% of the things. 我无法理解95%的事情。 Everything bellow API is somehow confusing. 以下所有API都在某种程度上令人困惑。 There are 0 examples of actually how something should be added to the build object. 实际上有0个例子应该如何添加到build对象中。 I mean, look at a simple dev request: I want to create windows and linux build. 我的意思是,看一个简单的开发请求:我想创建windows和linux build。 I copy/paste-ed some code and I came out with the fillowing: 我复制/粘贴了一些代码,然后我推出了填充:

{
  "name": "Test",
  "version": "1.0.0",
  "author": "Test Ltd.",
  "description": "Test",
  "devDependencies": {
      ...
  },
  "build": {
    "appId": "Test",
    "extraFiles": {
      "from": "./build",
      "to": "./dist"
    },
    "win": {
      "icon" : "build/images/icon.ico",
      "target": ["portable"]
    },
    "linux": {
      "icon" : "build/images/icon.png",
      "target": ["pacman"]
    }
  },
  "scripts": {
    "pack": "build --dir",
    "dist": "build"
  }
}
  1. It creates only x64 windows package. 它只创建x64 windows包。 In the dist folder there is a folder called win-unpacked and one .exe file. dist文件夹中有一个名为win-unpacked的文件夹和一个.exe文件。 The linux package is not there. linux包不存在。 Why? 为什么?
  2. How to specify the arch (x64, x32)? 如何指定拱门(x64,x32)?
  3. How to use the things bellow API ? 如何使用贝娄API的东西? I understood only how WinBuildOptions work - I should write "win" in the "build" object of package.json . 我只了解WinBuildOptions是如何工作的 - 我应该在package.json的“build”对象中写“win”。
  4. What is Squirrel Events ? 什么是Squirrel Events I red this , but can't understand it from plain text. 我红了这个 ,但是从纯文本中无法理解。
  5. Any recommendations for a video guide for "How to create an installer for Windows with Electron/electron-builder?" 有关“如何使用Electron / electron-builder创建Windows安装程序?”的视频指南的任何建议。 or "How to create package for Linux and upload it online so people with Linux can download it with Electron/electron-builder?" 或者“如何为Linux创建软件包并在线上传,以便Linux用户可以使用Electron / electron-builder下载它?” I couldn't find any. 我找不到任何东西。

Take a look a the api options in the github repo for electron-builder , which uses the windows build options and linux build options to work. 看看电子生成器的github repo中的api选项,它使用windows构建选项和linux构建选项来工作。 The descriptions of each item are laid out next to the attribute/property of the config. 每个项目的描述都布置在配置的属性/属性旁边。

This is a contrived example, but should at least give the structure of how it should look for windows and linux: 这是一个人为的例子,但至少应该给出它应该如何寻找windows和linux的结构:

    "build":{
        "appid":"yourid",
        "asar": true
        "linux":{
            "category": "...",
            "target": "..."
        },
        "win":{
            "target": "...",
            "certificateFile":"...",
            "publisherName": "..."
        }

    }

There is a multi platform build page you can review. 您可以查看多平台构建页面。 Specifically, to target a certain arch, you use the command line flags. 具体来说,要使用某个arch,请使用命令行标志。 From the documentation: 从文档:

By default build for current platform and current arch. 默认情况下,为当前平台和当前arch构建。 Use CLI flags --mac, --win, --linux to specify platforms. 使用CLI标志--mac, - win, - linux来指定平台。 And --ia32, --x64 to specify arch. 并且--ia32, - x64指定arch。

Typically, this is specified as an npm script, and passed along that way when you run the electon-build command. 通常,这被指定为npm脚本,并在运行electon-build命令时以这种方式传递。 In terms of building on platforms and potentially missing information, please see this quote: 在建立平台和可能缺少信息方面,请看这个引用:

Don't expect that you can build app for all platforms on one platform. 不要指望您可以在一个平台上为所有平台构建应用程序。

There appears to be extra setup and configuration needed to develop a linux and windows version based on the specific OS you are using. 根据您使用的特定操作系统开发Linux和Windows版本似乎需要额外的设置和配置。 I would look at what that page states in terms of dependencies. 我会看看该页面在依赖关系方面的含义。

To answer part of your question you can not package an app when you are not on the platform that you want to package for example if you are on window the electron-builder will package windows app based on the machine you are using configuration of win targets 要回答部分问题,当您不在要打包的平台上时,无法打包应用程序,例如,如果您在窗口,电子建设者将根据您正在使用win目标配置的计算机打包Windows应用程序

For linux targets, see here . 对于linux目标,请参见此处 The recommendation seems to be to build inside a docker container if you want to build for linux. 如果你想为linux构建,建议似乎是在docker容器内部构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM