You can add files to the final asar using electron-builder
's extraFiles
field in package.json
.
In package.json,
"build": {
"additionalFiles": {
"from": "resources/${os}/myBin",
"to": "Resources/bin/myBin",
"pattern": "**/*"
}
}
In the main process,
import path from 'path'
import { execFile } from 'child_process'
const execPath = path.join(process.resourcesPath, 'bin/myBin')
const env = {}
execFile(execPath, { env }, (error, stdout, stderr) => {
// do something...
})