appinteractive/electron-vite-tailwind-starter

Implementation of "Preload"

Opened this issue · 1 comments

Hi,

I am implementing the security tip from Electron.
https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content

But this has no effect, I don't know if it's because vite and electron run independently of each other.

create-window.js

- nodeIntegration: true,
+ preload: path.join(app.getAppPath(), 'preload.js'),

preload.js

const { ipcRenderer } = require('electron')
window.ipcRenderer = ipcRenderer

index.html

  <script>
    alert(window.ipcRenderer) // Return: "undefined"
  </script>

Could you support me with this problem?

I was thinking about implementing this package to solve that issue:
https://github.com/frankwallis/electron-ipc-proxy or https://github.com/geblanco/electron-router

Would that help in your case? I already spit main and renderer and switched to typescript in the latest iteration, the next step would be to setup a communication channel.