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!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.189.247