I am new to electron. I have an angular application wrapped in electron that I want to build the package/installer using electron-builder
. I am using electron-builder-config.yaml
file to build the installer.
I would like to know how do I read values from .env
environment file into electron-builder-config.yaml
file ?
I want to set the version of the package that is generated by command electron-builder -w --publish always -c ./builder-config.yaml
.
I did try using buildVersion
property but the problem is that there is an installer.nsh
file that needs to run as part of nsis installer to set the path and that file uses ${version}
.
There is very little documentation on environment variables usage in electron-builder-config.yaml
Here is my electron-builder-config.yaml
directories:
output: ./dist/electron
buildResources: ./electron/build
app: ''
electronVersion: X.Y.Z
appId: com.sample.app
copyright: "Copyright © 2020 ${author}"
productName: TestApp
forceCodeSigning: true
artifactName: "${productName}-${os}-${version}.${ext}"
files:
- "**/dist/electron/*"
- "**/electron/*"
asar: true
compression: maximum
mac:
category: public.app-category.reference
icon: "./icon-file.icns"
publish: [{
"provider": "generic",
"url": "http://localhost:8080"
}]
dmg:
background: "./build/sample.jpg"
icon: "./build/nw.icns"
iconSize: 96
contents:
- x: 650
y: 230
type: link
path: /Applications
- x: 350
y: 230
type: file
win:
cscLink: "./somelink.pfx"
cscKeyPassword: "XXXXXX"
target: [nsis]
icon: "./appinfo.ico"
publish: [{
"provider": "generic",
"url": "http://localhost:8080"
}]
msi:
shortcutName: "TestApp - ${version}"
createDesktopShortcut: true
createStartMenuShortcut: true
nsis:
include: "./installer.nsh"
installerIcon: "./appinfo.ico"
uninstallerIcon: "./appinfo.ico"
packElevateHelper: true
allowToChangeInstallationDirectory: true
perMachine: true
oneClick: false
createDesktopShortcut: true
createStartMenuShortcut: true
shortcutName: "TestApp - ${version}"
guid: "someguid"
npmRebuild: true
nodeGypRebuild: false
Also, I am not sure about the macro ${ext}
. From where does this electron-builder-config.yaml
file is picking up this value ? Even in the documentation for file-macros, the version does not have the clear definition. Any suggestions ?