电子伪造的打包应用程序显示空白屏幕

时间:2020-02-10 17:42:48

标签: javascript electron electron-forge

我正在开发电子应用程序,并使用电子伪造,我使用webpack和typescript模板启动了一个新项目,未对配置进行任何重大更改,但是打包应用程序的时间到了黑屏。

如果我使用yarn start启动我的应用程序,那么一切正常,但是运行yarn package并打开该应用程序后,我得到的只是一个空白屏幕,控制台完全没有显示错误,它仍然是空白。 / p>

主要index.ts文件:

import { app, BrowserWindow } from "electron";
import path from "path";
declare const MAIN_WINDOW_WEBPACK_ENTRY: any;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: any;

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
  // eslint-disable-line global-require
  app.quit();
}

const createWindow = () => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    height: 600,
    width: 800,
    webPreferences: {
      webSecurity: false,
      nodeIntegration: true,
      preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
    }
  });

  // and load the index.html of the app.
  mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);

  // Open the DevTools.
  // mainWindow.webContents.openDevTools();
};

渲染器代码:

import "../assets/base.css";
import React from "react";
import { render } from "react-dom";
import App from "./App";

render(<App />, document.getElementById("app"));

declare let module: { hot: any };

if (module.hot) {
  module.hot.accept("./App", () => {
    const NewApp = require("./App").default;

    render(<NewApp />, document.getElementById("app"));
  });
}

我对webpack配置所做的唯一更改是添加了postCSS来加载顺风,除了它是默认配置之外,该应用会编译并生成.app文件,但不会加载任何内容。

终端输出也没有显示任何错误:

> yarn package
yarn run v1.19.2
warning ../package.json: No license field
$ electron-forge package
✔ Checking your system
✔ Compiling Main Process Code
⠋ Compiling Renderer TemplateStarting type checking service...
Using 1 worker with 2048MB memory limit
✔ Compiling Renderer Template
✔ Preparing to Package Application for arch: x64
✔ Preparing native dependencies
✔ Packaging Application
✨  Done in 8.06s.

有什么建议吗?

0 个答案:

没有答案