Multi Platform Build - Electron-Builder
Multi Platform Build - Electron-Builder
Multi Platform Build - Electron-Builder
Info
Don’t expect that you can build app for all platforms on one platform.
If your app has native dependency, it can be compiled only on the target
platform unless prebuild [https://www.npmjs.com/package/prebuild] is not
used.
By default build for current platform and current arch. Use CLI flags --mac , --
win , --linux to specify platforms. And --ia32 , --x64 to specify arch.
electron-builder -mwl
https://www.electron.build/multi-platform-build 1/7
7/18/2020 Multi Platform Build - electron-builder
Build performed in parallel, so, it is highly recommended to not use npm task per
platform (e.g. npm run dist:mac && npm run dist:win32 ), but specify multiple
platforms/targets in one build command. You don’t need to clean dist output
before build — output directory is cleaned automatically.
matrix:
include:
- os: osx
osx_image: xcode10.2
language: node_js
node_js: "10"
env:
- ELECTRON_CACHE=$HOME/.cache/electron
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
- os: linux
services: docker
language: generic
cache:
directories:
- node_modules
- $HOME/.cache/electron
- $HOME/.cache/electron-builder
script:
- |
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
docker run --rm \
--env-file <(env | grep -iE
'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS|APPVEYOR_|CSC_|_TOKEN|_KEY|AWS_
\
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
/bin/bash -c "yarn --link-duplicates --pure-lockfile && yarn release --
linux --win"
else
yarn release
fi
before_cache:
- rm -rf $HOME/.cache/electron-builder/wine
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"
https://www.electron.build/multi-platform-build 2/7
7/18/2020 Multi Platform Build - electron-builder
sample appveyor.yml
platform:
- x64
cache:
- node_modules
- '%USERPROFILE%\.electron'
init:
- git config --global core.autocrlf input
install:
- ps: Install-Product node 10 x64
- yarn
build_script:
- yarn dist
test: off
macOS
All required system dependencies (except rpm) will be downloaded
automatically on demand on macOS 10.12+ (macOS Sierra). On Travis, please
add osx_image: xcode10.2 (see above sample .travis.yml ).
https://www.electron.build/multi-platform-build 3/7
7/18/2020 Multi Platform Build - electron-builder
Linux
You can use Docker [#docker] to avoid installing system dependencies.
To build snap if and only of you have custom stage packages (if you don’t have
custom snap build configuration, you don’t need to install). See snapcraft
[https://snapcraft.io/snapcraft] in Store.
https://www.electron.build/multi-platform-build 4/7
7/18/2020 Multi Platform Build - electron-builder
Travis Linux
Xenial [https://docs.travis-ci.com/user/trusty-ci-environment/] is required.
sudo: required
dist: xenial
Travis macOS
osx_image: xcode10.2
Docker
To build Linux or Windows on any platform.
Warning
You cannot build for Windows using Docker if you have native dependencies and native
dependency doesn’t use prebuild [https://www.npmjs.com/package/prebuild].
Note
Do not use Docker Toolbox on macOS. Only Docker for Mac [https://docs.docker.com/docker-
for-mac/install/] works.
https://www.electron.build/multi-platform-build 5/7
7/18/2020 Multi Platform Build - electron-builder
'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAV
\
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine
Tip
If you don’t need to build Windows, use image electronuserland/builder (wine is not installed
in this image).
https://www.electron.build/multi-platform-build 6/7
7/18/2020 Multi Platform Build - electron-builder
https://www.electron.build/multi-platform-build 7/7