官术网_书友最值得收藏!

Packaging for Ubuntu

The process of packaging your application for Ubuntu doesn't differ much from that of macOS. Let's get started:

  1. You need to provide an application identifier and a category in the linux section of the package.json file:
      {
"build": {
"appId": "com.my.app.id",
"linux": {
"category": "Utility"
}
}
}
Please note that you can declare settings for Linux alongside those for other platforms, which is handy when you're developing for multiple operating systems or switching between them. The same applies to the scripts section. In this book, we are going to use different script names so that you can merge them into a single configuration.
  1. Update your package.json file and append the following scripts to it so that you can build your application in development mode and distribution mode:
      {
"scripts": {
"start": "electron .",
"build:linux": "electron-builder --linux --dir",
"dist:linux": "electron-builder --linux"
}
}
  1. Let's ensure that we can build the application for local testing. Run the first script in the Terminal window:
      npm run build:linux
  1. In the project's root, you should see the dist/linux-unpacked folder, which contains several build artifacts:
  1. Now, let's see what you get when you're building packages for distribution. Run the second command, as shown in the following code:
      npm run dist:linux
  1. This time, you are going to get multiple packages in the dist folder, as shown in the following screenshot:

The files that will be in your output folder are as follows:

  • my-first-app 1.0.0.AppImage: The AppImage format is a universal software packaging format for all GNU/Linux distros.
  • my-first-app_1.0.0_amd64.snap: This is a snap file, another popular format for sandboxed applications.
  • linux-unpacked/my-first-app: This is the unpacked build for local testing and custom distributions.
  1. For now, double-click on my-first-app 1.0.0.AppImage to run the app. If you get the Would you like to integrate my-first-app with your system dialog, click No.
  2. This will be your final output:

Congratulationsyou've got your first cross-platform Electron application package up and running on Ubuntu Linux!

主站蜘蛛池模板: 太仆寺旗| 沙湾县| 扬州市| 商河县| 泽普县| 富锦市| 那曲县| 东兰县| 同心县| 徐汇区| 台山市| 铁岭县| 乐安县| 丰城市| 巫山县| 高阳县| 玉山县| 凤冈县| 舒城县| 攀枝花市| 赣榆县| 临西县| 泗水县| 沾化县| 海宁市| 乌鲁木齐市| 元谋县| 西宁市| 宜良县| 铜川市| 旅游| 湖南省| 栾城县| 长兴县| 盘锦市| 北辰区| 岳阳市| 普安县| 崇仁县| 青河县| 衡东县|