I’m trying to get electron into this HTML file, but require is undefined:
<script>
const electron = require("electron");
const {icpRenderer} = electron;
const form = document.querySelector("form");
form.addEventListener("submit", submitForm);
function submitForm(e){
e.preventDefault();
const item = document.querySelector("#item").value;
}
</script>
I have nodeIntegration as True, and contextIsolation as True for the web preferences which is used to prevent security warnings. How can I get require through this file?
Guide Video Adding Script tags
In main.js:
function createAddWindow(){
addWindow = new BrowserWindow({
width: 300,
height: 200,
title: "Add Inventory Item",
webPreferences: {
nodeIntegration: true,
worldSafeExecuteJavaScript: true,
contextIsolation: true
}
});
addWindow.loadURL(url.format({
pathname: path.join(__dirname, "addWindow.html"),
protocol: "file",
slashes: true
}));
addWindow.on("close", function(){
addWindow = null;
})
}