From b5d1bba5175e7b4938b68a5db579f8b40e6539fc Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Mon, 6 May 2019 22:35:09 +0900 Subject: [PATCH] Set nodeIntegration for webview to use ipc, process and require in renderer process --- src/main/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index d1adb860..852bf44d 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -203,7 +203,6 @@ async function createWindow() { defaultWidth: 1000, defaultHeight: 563 }) - // mainWindow = new BrowserWindow({ const mainOpts: BrowserWindowConstructorOptions = { titleBarStyle: 'hidden', x: mainWindowState.x, @@ -211,7 +210,12 @@ async function createWindow() { width: mainWindowState.width, height: mainWindowState.height, useContentSize: true, - icon: path.resolve(__dirname, '../../build/icons/256x256.png') + icon: path.resolve(__dirname, '../../build/icons/256x256.png'), + webPreferences: { + // It is required to use ipcRenderer in renderer process. + // But it is not secure, so if you want to disable this option, please use preload script. + nodeIntegration: true + } } const config: Config = { windowOpts: mainOpts,