0

我正在开发一个电子应用程序并使用 electron-forge,我使用 webpack 和 typescript 模板开始了一个新项目,没有对配置进行任何重大更改,但是到了打包应用程序的时候了,我得到的只是一个空白屏幕.

如果我在一切正常的情况下启动我的应用程序yarn start,但是在运行yarn package并打开应用程序后,我得到的只是一个空白屏幕,控制台根本没有显示任何错误,它仍然是空白的。

主 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 以加载 tailwind,而不是它是默认配置,应用程序编译并生成 .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.

有什么建议么?

4

0 回答 0