2
votes

OS: Windows

Tech Stack: ElectronJS with electron-builder npm package

I am using the fileAssociations property in package.json (I am using electron-builder). In that configuration, I can set my application to be the default file handler for a file extension and optionally set an icon to be displayed on those files. My question is:

Is it possible to set different icons for different file types using electron-builder configuration?

For example, icon 'A.ico' for file extension 'abc' and 'B.ico' for file extension 'xyz' that my application is the default for?

1

1 Answers

1
votes

So finally I found the answer which was rather straightforward (Thanks to the infamously improper documentation of electronJS (and of related packages), it wasn't so obvious at first!) In case anyone else is going through the same problem, here is the solution:

Create an array of different fileAssociation objects each having their own extension and icon properties. Then each icon will be linked to its own extension.

Example:

fileAssociations: [
  {
     ext: 'abc',
     icon: 'resources/icons/abc'
  },
  {
     ext: 'xyz',
     icon: 'resources/icons/xyz'
  }
]