appinteractive / electron-vite-tailwind-starter

This Starter utilizes Electron, Vite and Tailwindcss in combination. It trys to adhare best practices.
MIT License
145 stars 18 forks source link

Implementation of "Preload" #83

Open joserick opened 3 years ago

joserick commented 3 years ago

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?

appinteractive commented 3 years ago

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.