Electron Specific entry point in package.json


#1

I’m working with an existing codebase, which we are looking to have optionally built for electron .

This has been going well, with the one exception of actually compiling the application and the problem is relatively straight forward: electron requires the main entry point to be defined in package.json. If I specify that everything works without a hitch.

The rub here is that, this is a conditional build of the codebase, and the main script then becomes specific to electron.

So what I’m wondering is if there is a way to define an electron specific entry point in package.json. Something along the lines of:

{
    "main": {
        "electron": "path/to/electron-entry-point.js"
    }
}

I’ve tried alternative approaches, such as skipping the definition of main script altogether and creating a symlink to my entry point as index.js . I’ve had mixed results with this approach and it seems janky.