Exclude some folders, while doing electron-packager . --asar

后端 未结 2 1716
一向
一向 2021-01-14 10:54

I use \'electron-packager . --asar\' command to package my project folder. but there are some folders which must not be included while packaging.

  1. Is it poss

相关标签:
2条回答
  • 2021-01-14 11:30

    Is it possible to exclude some of folders?

    Yes, you can do it with ignore

    You can use --ignore to ignore files and folders via a regular expression (not a glob pattern). Examples include --ignore=.gitignore or --ignore=".git(ignore|modules)".

    Take a look at API document here

    If so, I would like to include those folders in exe file path so that the user can manage their files. Is there any way to do this?

    You can use extraResource API to include them to resources directory (document here):

    extraResource

    String or Array of Strings

    One or more files to be copied directly into the app's Contents/Resources directory for OS X target platforms, and the resources directory for other target platforms.

    Hope this help.

    0 讨论(0)
  • 2021-01-14 11:43

    I had similar problem. I wanted to exclude qpdf folder containing (*.exe, *.dll) from asar package. My qpdf.exe could not run without needed linked .dll directly from asar package.

    I just added --extra-resource parameter into electron packager syntax where I am excluding whole qpdf folder. This folder and all files inside are then in resource folder with asar package.

    Part of my package.json

     "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "electron .",
        "package-win": "electron-packager . hiss_xread --overwrite --extra-resource=\"./qpdf\" --asar --platform=win32 --arch=x64 --icon=src/xRead.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Hiss xRead\""
      },
    

    Resource folder in builded app look like this.

    0 讨论(0)
提交回复
热议问题