Is there a good solution on how to include third party pre compiled binaries like imagemagick into an electron app? there are node.js modules but they are all wrappers or na
Heavily based on Ganesh's answer, but simplified somewhat. Also I am using the Vue CLI Electron Builder Plugin so the config has to go in a slightly different place.
resources
directory. Place all your files in there.vue.config.js
:module.exports = {
pluginOptions: {
electronBuilder: {
builderOptions: {
...
"extraResources": [
{
"from": "resources",
"to": ".",
"filter": "**/*"
}
],
...
}
}
}
}
resources.ts
in your src
folder, with these contents:import path from 'path';
import { remote } from 'electron';
// Get the path that `extraResources` are sent to. This is `/Resources`
// on macOS. remote.app.getAppPath() returns `/Resources/app.asar` so
// we just get the parent directory. If the app is not packaged we just use
// `/resources`.
export const resourcesPath = remote.app.isPackaged ?
path.dirname(remote.app.getAppPath()) :
path.resolve('resources');
Note I haven't tested this on Windows/Linux but it should work assuming app.asar
is in the resources directory on those platforms (I assume so).
import { resourcesPath } from '../resources'; // Path to resources.ts
...
loadFromFile(resourcesPath + '/your_file');