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

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!

主站蜘蛛池模板: 蕲春县| 银川市| 桓台县| 万载县| 焉耆| 界首市| 恭城| 涿鹿县| 嘉鱼县| 瓮安县| 洪湖市| 阳朔县| 永福县| 隆回县| 嘉黎县| 娱乐| 康平县| 铜川市| 贵港市| 双柏县| 永德县| 南岸区| 大埔县| 迁西县| 观塘区| 游戏| 江油市| 双鸭山市| 西乌珠穆沁旗| 饶河县| 深州市| 霸州市| 磐安县| 大方县| 通化县| 通山县| 佛坪县| 房产| 宝山区| 卓尼县| 忻城县|