Skip to content

L007 - Package the app as a macOS bundle #16

@icanzilb

Description

@icanzilb

Add electron-builder to your project, insert into package.json inside devDependencies:

"electron-builder": "^19.45.4"

Now run in the console the command to install this new package into your project:

yarn install

Further add the config for building your app - again in package.json, this time in the top of the hierarchy:

"build": {
    "appId": "com.marinisthebest.app",
    "files": [
      "build/**/*",
      "node_modules/**/*"
    ],
    "directories": {
      "buildResources": "assets"
    },
    "mac": {
      "target": ["dir"]
    },
    "compression": "store",
    "asar": true
  }

You can read on all config options here: https://www.electron.build/configuration/configuration

Add two new scripts to "scripts" section:

    "preelectron-pack": "yarn build",
    "electron-pack": "build --em.main=build/electron.js"

electron-pack is the script which builds your app. Go to the console and run it:

yarn run electron-pack

This will build your app and save it in a sub-folder called dist in your project

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions