Call ipcRenderer in Electron + React.js App

April 4, 2020

When you develop Electron application with React.js you have to do Inter Process Communication (IPC) between your react component and mail process.

Forexample if you send message to main process you have to use the following code

var electron = require('electron');
var ipc = electron.ipcRenderer;
 
// send sync messages
ipc.sendSync('updataData',{x:1,y:2})

But when you build the App you will get build errors

So to get rid of this build error I m using following configuration in my webpack.config.js

plugins: [
        new webpack.ExternalsPlugin('commonjs', [
            'electron'
        ])
    ]