Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 3.23 KB

packaging-your-app.md

File metadata and controls

77 lines (54 loc) · 3.23 KB

How to pack and build your Electron app for all platforms

In addition to Electron's minimal app, this repository uses two very useful npm packages:

  • Electron packager: this package parses your app folder and creates the files needed to launch the app on any platform that you specify
  • Electron builder: this package starts with the files generated by electron-packager and creates a single installer for OSX or Windows computers to help you easily distribute your app.

Pre-requisites

If you are on OS X/Linux and want to build for Windows, you need Wine installed. Wine is required in order to set the correct icon for the exe.

You will also need the nullsoft scriptable install system for all platforms.

On OS X, via Homebrew

$ brew install wine makensis

On Ubuntu(-based) Linux distributions, via apt:

# add-apt-repository ppa:ubuntu-wine/ppa -y
# apt-get update
# apt-get install wine nsis -y

This package provides us with a command-line tool to package and serve our app.

The command syntax is as follows:

electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> --version=<Electron version> [optional flags...]

The package then parses all files in the <sourcedir> and outputs the needed files to run the app to the directory you can specify with the optional --out flag.

You can find the complete official documentation here and how we implemented it for each platform in our package.json file.

This package provides us with a command-line tool to compile the files generated by electron-packager in a unique installer file.

The command syntax is as follows:

electron-builder <sourcedir> --platform=<platform> --config=<configPath> --out=<outputPath>

This package parses and compresses the files created by electron-packager located in the <sourcedir> to create an installer for OSX or Windows. You will then be able to distribute this file (either .exe or .dmg) to allow users to install your app on their computers.

You can find the complete official documentation here and how we implemented for OSX and Windows platforms in our package.json file

A typical configuration file for this package is:

{
  "osx" : {
    "title": "my-awesome-app",
    "background": "assets/osx/my-awesome-app.png",
    "icon": "assets/osx/my-awesome-app.icns",
    "icon-size": 80,
    "contents": [
      { "x": 438, "y": 344, "type": "link", "path": "/Applications" },
      { "x": 192, "y": 344, "type": "file" }
    ]
  },
  "win" : {
    "title" : "my-awesome-app",
    "icon" : "assets/win/icon.ico"
  }
}

You can find all the available options on the official documentation.

Congratulations, you are now able to deploy your app to any platform and conquer the world!