Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron | Blank window after build #61

Open
Flob10 opened this issue Apr 1, 2020 · 2 comments
Open

Electron | Blank window after build #61

Flob10 opened this issue Apr 1, 2020 · 2 comments

Comments

@Flob10
Copy link

Flob10 commented Apr 1, 2020

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

@Muhammad-Taif-Khan
Copy link

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

Hi i faced the same issue did you fix. If you fixed it please explain

@Flob10
Copy link
Author

Flob10 commented Jul 29, 2021

Hi Muhammad,
Unfortunately, I didn't fix it.
The best way to use a PHP back-end with Electron seems to build an API with PHP that can be requested in your Electron project (that is what I did but I could'nt make gulp work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants