In this tutorial we’ll create a DMG installer for the Electron tutorial app. To create a DMG installer you first need to package the app. Read that tutorial first if you haven’t already.
1. Installing package
Open up a terminal and run these commands:
2. Creating the DMG installer
This is the basics that we need to create the DMG. First run the package-mac script that we created to create a package for the mac in the electron packager tutorial:
This will create a package for us in the release-builds folder. So now we can create the DMG with this command:
This will create a file called electron-tutorial-app.dmg in the root folder of the application. The dmg will use default settings. In the next step we’ll look at what settings we can do to it.
If we look at the file usage.txt we can see that we have some options to make when it comes to the installer:
As you see above we can set the out path of the .dmg file that is generated. We can set an icon that the dmg-window will use (By default this was the electron icon when i tried). We can set the icon size and custom background for the window.
Since the packages are created in the release-builds folder we’ll create the installers there as well. We also already have the icon created for the application (this is done in the icon tutorial)
The command to run now looks like this:
4. Creating a script
I am one of those that won’t be able to memorize that string. So we can add it to our scripts package.json: