Redplane
Redplane

Reputation: 3151

Prevent electron-builder from packaging required node_modules

I'm using electron-builder to build my electron application as a desktop app. The build was fine, but its size was very large (68Mb).

When I used asar explorer to view my app.asar file. I realize that the app.asar file contains a folder named node_modules, in the node_modules, there are npm folders that have been bundled using webpack, such as: angular, angular-messages, ui-cropper, ...

List of required folders

How can I ignore those folder from being included in app.asar file ?

They have been bundled by webpack before.

Thank you

Upvotes: 1

Views: 4489

Answers (1)

Hai Pham
Hai Pham

Reputation: 2225

You could define which file will be included by using "files" section in package.json:

{
    "name": "MyApp",
    ...
    "build": {
        "files": [
            "node_modules",
            "!node_modules/module-x/*" //prevent module x to be included
        ]
    }
    ...
}

Hope this helps

Upvotes: 3

Related Questions