bundling precompiled binary into electron app

后端 未结 6 1701
无人共我
无人共我 2020-11-28 22:21

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

6条回答
  •  臣服心动
    2020-11-28 23:10

    following Ganesh answer's which was really a great help, in my case what was working in binaries.js (for a mac build - did not test for windows or linux) was:

    "use strict";
    import path from "path";
    import { app } from "electron";
    
    const IS_PROD = process.env.NODE_ENV === "production";
    const root = process.cwd();
    const { isPackaged } = app;
    
    const binariesPath =
      IS_PROD && isPackaged
        ? path.join(process.resourcesPath, "./bin")
        : path.join(root, "./external");
    
    export const execPath = path.join(binariesPath, "./my_exec_name");
    

    Considering that my_exec_name was in the folder ./external/bin and copied in the app package in ./Resources/bin. I did not use the get_platforms.js script (not needed in my case). app.getAppPath() was generating a crash when the app was packaged. Hope it can help.

提交回复
热议问题