Skip to content

Electron | Blank window after build #61

Description

@Flob10

Hi!
I'm using gulp-connect-php for the first time. During my Electron app dev, everything was perfectly working. But, after running the build, I got a blank white window when opening the app. It seems that the app is not able to load the local url:
mainWindow.loadURL("http://127.0.0.1:8000")
instead of traditional:
mainWindow.loadURL('file://' + __dirname + '/index.html')

Here is my main.js
`const electron = require('electron');
const app = electron.app;
const { Menu, MenuItem } = electron;
const { ipcMain } = require('electron');

connect = require("gulp-connect-php");
var con = connect.server({
port: 8000,
hostname: "127.0.0.1",
base: 'public',
keepalive: false,
open: false,
root: "/",
stdio: "inherit"
});

const BrowserWindow = electron.BrowserWindow;

var mainWindow = null;

app.on('window-all-closed', function() {
if (process.platform != 'darwin') {
app.quit();
}
});

app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 800,
height: 800,
frame: false,
webPreferences: {
plugins: true,
nodeIntegration: true
}
});

mainWindow.maximize();

mainWindow.loadURL("http://127.0.0.1:8000");

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

Menu.setApplicationMenu(null);
});`

It works well, but only when developing the app. I'm using electron-builder.
Maybe that's not an issue. Is there something wrong with this code ?

Thanks

EDIT : I should precise the entry file of my app is /public/index.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions