forge: Ignoring native build directories not working during packaging

Please describe your issue:

I m not able to ignore some directories when packaging the app. I m using sqlite3 module and it’ll generate intermediate build directory in node_modules\sqlite3\build path, it is be around 25MB which I don’t want to part of the app. Can shave ~25MB of the total app size.

I m ignoring using electronPackagerConfig.ignore, like below:

"electronPackagerConfig" : {
    "ignore": [
        ".vscode",
        "node_modules/sqlite3/build"
    ]
}

But it seems, the electron-package is running before the native build and thus above ignore is of no use. I’ve seen this behavior by checking the %temp%\electron-package\ directory where the packaging is happening.

To prove the above, .vscode directory is not included in the app.asar as I’ve it in the ignore list. And similarly, if I use node_modules/sqlite3, then the complete sqlite3 directory is not getting bundled and then I m getting native build failed error which is expected.

Is this the expected order (first package, then build)? If this is the expected order, how to ignore directories which will be created during the native builds?

config.forge data in package.json:

"forge": {
    "make_targets": {
        "win32": ["squirrel"],
        "darwin": ["zip"],
        "linux": ["deb","rpm"]
    },
    "electronPackagerConfig": {
        "ignore": [
            ".vscode",
            "node_modules/sqlite3/build"
        ]
    },
    "electronWinstallerConfig": {
        "name": "electron_forge_demo"
    },
    "electronInstallerDebian": {},
    "electronInstallerRedhat": {}
}

Repro repo: https://github.com/manikantag/electron-forge-native-binaries-issue

Generate package: npm run package Verify if sqlite3/build is present or not: asar l app.asar | grep build

OS details: Windows 8.1 x64

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

But it seems, the electron-package is running before the native build and thus above ignore is of no use.

This is accurate, you need to use an afterCopy hook to delete the artifacts you don’t want from the native module build process.

/cc @malept I don’t think we should do this ^^ by default as some people may want the debug artifacts. What do you think?