question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

only a blank screen after build

See original GitHub issue
  • 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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
didmehhcommented, Oct 4, 2018

@gen4sp I had resolved it by use hashRouter replace browserRouter

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

0reactions
cnscorpionscommented, Dec 8, 2020

@didmehh thank you, it works for guys who use react-router with BrowerRouter 大兄弟救了命🤣

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix the Blank screen After a Static Deployment with ...
Blank, white screen in the browser. It's one of the most annoying situations after deploying a static React app: After all that work, ......
Read more >
How to fix the white screen after build with create-react-app?
I just uploaded all my files from the build folder to s3. When I load my S3, it is showing blank screen and...
Read more >
How to fix the Whitescreen After a Static Deployment with ...
After installing polyfills, my home screen finally showed up, but any other screen is a blank white screen. ** This only happens in...
Read more >
Blank screen after build package (dev works) #672 - GitHub
I encountered following strange behaviour of my app: My dev application works like a charme but if I package my app the inital...
Read more >
Site is live, but sill blank screen (react app) - Support
Hi, I have the same issue, my react-app shows a blank screen after successful build. Index.html is in the public folder. Publish directory ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found