electron-builder
electron-builder copied to clipboard
extraMetadata not working
- Electron-Builder Version: 23.4.0
- Node Version: v16.16.0
- Electron Version: 19.0.12
- Electron Type (current, beta, nightly): current
- Target: linux, mac
Using Electron Forge and Electron Builder to develop and build Electron app.
Somehow, extraMetadata
props do not make their way to package.json
when using following config.
$ cat electron.config.js
module.exports = {
appId: "com.sunknudsen.test",
artifactName: "test-${version}.${ext}",
productName: "Test",
dmg: {
title: "${productName}",
},
linux: {
target: {
arch: "x64",
target: "AppImage",
},
},
mac: {
target: {
arch: "universal",
target: "dmg",
},
},
files: [
{
from: "./out/Test-darwin-arm64/Test.app/Contents/Resources/app",
to: ".",
},
],
asarUnpack: ["**/bin/**/*", "!**/node_modules/**/*"],
extraMetadata: {
foo: "bar",
},
}
$ electron-forge make && electron-builder --config ./config/electron.config.js --linux --mac
Can’t figure out what I am doing wrong… either I don’t understand feature or perhaps there is a bug.
Resulting package.json
does not include any reference to foo
prop.
Loosing my mind… just noticed packaged package.json
is actually untouched by electron-builder
… file is essentially copied from ./out/Test-darwin-arm64/Test.app/Contents/Resources/app/package.json
.
Would anyone happen to know why electron-builder
is not removing scripts
and keywords
alongside not including props from extraMetadata
?
Thanks for helping out!
Figured out what causes the issue… srcDir
is set to project root rather than ./out/Test-darwin-arm64/Test.app/Contents/Resources/app
.
Investigating fixes…
Adding following to files
array fixed issue but feels like a hack… would be nice if one could set srcDir
.
{
filter: "package.json",
from: ".",
to: ".",
}