electron-affinity icon indicating copy to clipboard operation
electron-affinity copied to clipboard

Not working with webpack minimization

Open fwdillema opened this issue 2 years ago • 3 comments

Hi,

I made an electron app using electron-forge and its builtin typescript/webpack template, using:

yarn create electron-app my-new-app --template=typescript-webpack

In such a setup, webpack minimizes the javascript code in production mode (but not in development mode). The minimization removes the constructor.name from classes which is used by electron-affinity to retrieve the className of the rpc API (most notably in exposeAPI()). This makes the application fail in production mode as the RPC api is not found by the renderer process (as it is registered with an empty name).

I am not sure whether this can/should be fixed by electron-affinity, but it is good to add this to the documentation to spare other users the time to figure this one out.

I have solved this problem for now by switching off minimization in the webpack configuration file webpack.main.config.js:

optimization: { minimize: false },

but that is more a workaround than a proper solution.

fwdillema avatar Jun 27 '22 15:06 fwdillema