Free public electron-build-service is used to build Electron app for Linux on Windows. On macOS/Linux you can build Electron app for Windows locally, except Appx for Windows Store (in the future (feel free to file issue) electron-build-service will support Appx target).
You can use build servers — e.g. Travis to build macOS/Linux apps and AppVeyor to build Windows app.
By default build for current platform and current arch. Use CLI flags
For example, to build app for MacOS, Windows and Linux:
Sample
See sample .travis.yml.
Sample
Use AppVeyor only if:
See sample appveyor.yml.
To build rpm:
To build app in distributable format for Linux:
To build pacman:
To build snap:
See example Docker usage on a CI server in the sample .travis.yml.
If you don't need to build Windows, use image
NOTICE: Do not use Docker Toolbox on macOS. Only Docker for Mac works.
--------
https://github.com/electron-userland/electron-build-service
You can use build servers — e.g. Travis to build macOS/Linux apps and AppVeyor to build Windows app.
By default build for current platform and current arch. Use CLI flags
--mac
, --win
, --linux
to specify platforms. And --ia32
, --x64
to specify arch.For example, to build app for MacOS, Windows and Linux:
electron-builder -mwl
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.Sample .travis.yml
to Build Electron App for macOS, Linux and Windows
See sample .travis.yml.Sample appveyor.yml
to Build Electron App for Windows
Use AppVeyor only if:- you need to build AppX,
- or your app has native dependency and prebuilt binary is not provided.
.travis.yml
to build Windows on Linux using provided Docker image.See sample appveyor.yml.
macOS
All required system dependencies (except rpm) will be downloaded automatically on demand on macOS 10.12+ (macOS Sierra). On Travis, please addosx_image: xcode9.0
(see above sample .travis.yml
).To build rpm:
brew install rpm
(brew).Linux
You can use Docker to avoid installing system dependencies.To build app in distributable format for Linux:
sudo apt-get install --no-install-recommends -y libopenjp2-tools
To build rpm: sudo apt-get install --no-install-recommends -y rpm
(or sudo yum install rpm-build
).To build pacman:
sudo apt-get install --no-install-recommends -y bsdtar
.To build snap:
sudo apt-get install --no-install-recommends -y snapcraft
.To build app for Windows on Linux:
Docker (electronuserland/builder:wine
) is recommended to avoid installing system dependencies.- Install Wine (2.0+ is required) — see WineHQ Binary Packages.
- Install Mono (4.2+ is required) if you want to use Squirrel.Windows (NSIS, default target, doesn't require mono).
To build app in 32 bit from a machine with 64 bit:
sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib
Travis Linux
Trusty is required.sudo: required
dist: trusty
Travis macOS
macOS 10.12+ is required.osx_image: xcode9.0
Docker
To build Linux or Windows on any platform. You cannot build for Windows using Docker if you have native dependencies and native dependency doesn't use prebuild.See example Docker usage on a CI server in the sample .travis.yml.
Build Electron App using Docker on a Local Machine
- Run docker container:
docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--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 - Type in
yarn && yarn dist
If you don't havedist
npm script in yourpackage.json
, call./node_modules/.bin/electron-builder
directly.
/bin/bash -c "yarn && yarn dist"
You can use /test.sh
to install dependencies and run tests.If you don't need to build Windows, use image
electronuserland/builder
(wine is not installed in this image).NOTICE: Do not use Docker Toolbox on macOS. Only Docker for Mac works.
Provided Docker Images
builder:base
— Required system dependencies. Not supposed to be used directly.builder:9
orbuilder
— NodeJS 9 and required system dependencies. Based onbuilder:base
. Use this image if you need to build only Linux targets.builder:wine
— Wine, NodeJS 9 and required system dependencies. Based onbuilder:9
. Use this image if you need to build Windows targets.builder:wine-mono
— Mono for Squirrel.Windows. Based onbuilder:wine
. Use this image if you need to build Squirrel.Windows target.builder:wine-chrome
—google-chrome-stable
andxvfb
are available — you can use this image for headless testing of Electron application. Based onbuilder:wine
.
--------
https://github.com/electron-userland/electron-build-service