electron-vite/electron-vite-react

Security: Is there a better solution to import serialport without setting " nodeIntegration: true; contextIsolation: false"

gaspardruan opened this issue · 0 comments

I set the renderer plugin as document suggests, everything is fine with importing serialport when:

renderer({
      resolve: {
        serialport: { type: "cjs" },
      },
 })
win = new BrowserWindow({
    webPreferences: {
      contextIsolation: false,
      nodeIntegration: true,
    },
  });

But electron document said that this is not suggested for security.

So, I delete the two settings, then problem occured:
image

I wonder if there is a better solution to import serailport without the above settings.