hh54188
hh54188

Reputation: 15626

How to exclude file when build electron with electron-builder?

What I want is not exclude unused file, but exclude used file package into .exe file

I provide a file like config.json for user to edit some custom config, then the application could read the file to do something. So I don't hope this file package into .exe file.

How should I config electron-builder to exclude this file?

Upvotes: 3

Views: 7112

Answers (1)

snwflk
snwflk

Reputation: 3517

You can specify what files to package using the configuration, either inside package.json or in a separate config file for electron-builder.

The build section of the package.json contains the settings for electron-builder. The files key then contains information what to include in the package. The following example excludes the file foo.json.

{
    "name": "myApp",
    "version": "1.0.0",
    "description": "",


    "build": {
        "files": "!foo.json"
    }

}

There are many options available, e.g. to exclude several glob patterns or to specify exactly which files to included. You can also make all these settings platform-specific. For all options, see the docs.

Upvotes: 8

Related Questions