Electron-builder: only a blank screen after build

Created on 28 Jun 2018  路  7Comments  路  Source: electron-userland/electron-builder


  • Version:

    • electron: "^2.0.3"

    • electron-builder: "^20.16.0"


  • Target:
    current was dmg, if works, need to build for windows platform.

Current environment was a create-react-app product, i had reference From React to an Electron app ready for production.

the issue was dev work and build not work, it's only a blank screen.

some config:
package.json

...
"main": "public/electron.js",
"scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-scripts eject",
    "electron-dev": "concurrently \"BROWSER=none npm start\" \"wait-on http://localhost:3000 && electron .\"",
    "preelectron-pack": "npm run clean-dist && npm run build",
    "electron-pack": "build -c.extraMetadata.main=build/electron.js",
    "clean-dist": "rm -rf ./dist"
  },
"build": {
    "appId": "com.example.electron-cra",
    "productName": "test-cra",
    "files": [
      "build/**/*",
      "node_modules/**/*"
    ],
    "directories": {
      "buildResources": "assets"
    }
  },
...

public/electron.js

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

const path = require('path');
const url = require('url');
const isDev = require('electron-is-dev');
require('electron-debug')();

let mainWindow;

function createWindow() {
  mainWindow = new BrowserWindow({width: 900, height: 680});
  mainWindow.webContents.openDevTools()

  mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`);
  mainWindow.on('closed', () => mainWindow = null);
}

app.on('ready', createWindow);

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

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow();
  }
});

then in the chrome devTools, has some error:

Failed to load resource:  net::ERR_FILE_NOT_FOUND       main.4184e132.css
Failed to load resource:  net::ERR_FILE_NOT_FOUND       main.1445b1ba.js

because of electron version?

question

Most helpful comment

@gen4sp
I had resolved it by use hashRouter replace browserRouter

such as this error because of electron don't support code splitting? or 2167

All 7 comments

i'm resolve it by add homepage.
but another issue was

Failed to load resource:  net::ERR_FILE_NOT_FOUND       1.4e85fab7.chunk.js

such as this error because of electron don't support code splitting? or 2167

Sorry, issue not related to electron-builder. Maybe "asar": false will help you, but you need to investigate what's wrong with your loader.

thks. set "asar": false not work too, i think because of code splitting with react-router.

thks. set "asar": false not work too, i think because of code splitting with react-router.

Do you solve your issue? Have the same one

@gen4sp
I had resolved it by use hashRouter replace browserRouter

such as this error because of electron don't support code splitting? or 2167

@gen4sp
I had resolved it by use hashRouter replace browserRouter

such as this error because of electron don't support code splitting? or 2167

ok, thanks. It seems is not my case :(

If you have a icon defined in main.js (in any browser window) then the problem maybe that. And you can surely solve it. Check here https://stackoverflow.com/a/63936522/13114354

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StickNitro picture StickNitro  路  3Comments

leo picture leo  路  3Comments

iklemm picture iklemm  路  3Comments

omarkilani picture omarkilani  路  3Comments

talarari picture talarari  路  3Comments