Host website into electron


#1

Hello,

I have some issues to load JQuery into my hosted web page. Here is the main.js code :

'use strict';

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

var mainWindow = null;

app.on('window-all-close', function (){
    app.quit();
});

app.on('ready', function() {
    mainWindow = new BrowserWindow({width: 800, height: 600});   
    mainWindow.openDevTools();

    mainWindow.$ = mainWindow.JQuery = require('./modules/jquery-3.2.1.min.js');
    mainWindow.loadURL('http://hatmelia.azurewebsites.net');


    mainWindow.on('closed', function() {
        mainWindow = null;
    });
});

I tried without the mainWindow.... line and with the "node-integration": false parameter, nothing worked. I also trie with global. = global.JQuery = require(’./modules/jquery-3.2.1.min.js’); instead of doing this on the mainWindow. Nothing works. When the page is displayed in my dev tool i have these following errors :

Uncaught Error: jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.
hubs:17 Uncaught TypeError: Cannot read property 'signalR' of undefined(anonymous function) @ hubs:17(anonymous function) @ hubs:92
notification.min.js:1 Uncaught ReferenceError: $ is not defined

I would like if possible to simple load my page without adding any module, but if it s only jquery why not, but at this point , that didn’t worked.

Best regards,


#2

I don’t think you can load jQuery into renderer process from main process to renderer like this.