I am using Vue CLI 3 and vue-cli-plugin-electron-builder
to package my Vue Electron app and I am not able to get my preload.js script for electron working.
main window
win = new BrowserWindow({
width: 800,
height: 600
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, "/../src/preload.js") // works but window.electron.dialog in undefined
}
});
preload.js
const { dialog } = require("electron");
window.electron = {};
window.electron.dialog = dialog;
The window.electron.dialog
is always undefined in my Vue component - the import is clearly not working. Note that window.electron
is defined properly. I must be missing something.