简体   繁体   English

在电子锻造 + webpack 应用程序中使用电子构建器构建的应用程序显示空白屏幕

[英]App built using electron-builder in electron-forge + webpack application shows blank screen

I wanted to use electron-builder in my electron-forge (webpack-template and React) app, because of the more packaging options我想在我的电子锻造(webpack-template 和 React)应用程序中使用电子构建器,因为有更多的打包选项

electron-forge app was created with电子锻造应用程序是用

create electron-app test --template=webpack

This is my package.json这是我的package.json

  "name": "vocascan",
  "productName": "vocascan",
  "version": "1.0.0",
  "description": "My Electron application description",
  "main": ".webpack/main",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\"",
    "build": "electron-forge start && electron-builder --linux"
  },
  "keywords": [],
  "build": {
    "productName": "Vocascan",
    "files": [
    ],
    "linux": {
      "target": [
        "AppImage"
      ],
      "category": "Development"
    }
  },
  "license": "MIT",
  "config": {
    "forge": {
      "packagerConfig": {},
      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "mainConfig": "./webpack.main.config.js",
            "renderer": {
              "config": "./webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.jsx",
                  "name": "main_window"
                }
              ]
            }
          }
        ]
      ]
    },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.54",
    "@electron-forge/maker-deb": "^6.0.0-beta.54",
    "@electron-forge/maker-rpm": "^6.0.0-beta.54",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.54",
    "@electron-forge/maker-zip": "^6.0.0-beta.54",
    "@electron-forge/plugin-webpack": "6.0.0-beta.54",
    "@marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
    "css-loader": "^4.2.1",
    "electron": "10.1.5",
    "node-loader": "^1.0.1",
    "style-loader": "^1.2.1",
    "electron-builder": "^22.9.1"
  },
  "dependencies": {
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-react": "^7.12.5",
    "babel-loader": "^8.1.0",
    "electron-squirrel-startup": "^1.0.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  }

As you can see I added如您所见,我添加了

"build": "electron-forge start && electron-builder --linux"

and

"build": {
    "productName": "Vocascan",
    "files": [
    ],
    "linux": {
      "target": [
        "AppImage"
      ],
      "category": "Development"
    }
  },

in order to make electron-builder available为了使电子制造商可用

the build runs just fine, but when I start the app none of my components gets shown构建运行得很好,但是当我启动应用程序时,我的任何组件都没有显示

在此处输入图片说明


If someone needs the browser window code如果有人需要浏览器窗口代码

const createWindow = () => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
  });

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

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

and this is my folder structure这是我的文件夹结构

在此处输入图片说明

This template is NOT working with electron-builder.此模板不适用于电子制造商。

Because this template was designed to work with the electron-forge make command.因为此模板旨在与电子锻造 make 命令一起使用。 electron-builder can't work with it because it's using webpack dev server and not building a static build.电子构建器无法使用它,因为它使用 webpack 开发服务器而不是构建静态构建。 The template I linked is working with electron-builder because it's making a static build of react, the react components and the node modules you using and electron-builder can work with it.我链接的模板正在与电子构建器一起使用,因为它正在静态构建反应、反应组件和您使用的节点模块,并且电子构建器可以使用它。

I recommend this template: https://github.com/Levminer/create-electron-react-app我推荐这个模板: https : //github.com/Levminer/create-electron-react-app

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在使用electronic-builder构建的电子应用程序中包含Bootstrap - Including Bootstrap in an electron app built with electron-builder 使用带有电子编译和电子松鼠启动的电子锻造初始化电子应用程序时出错 - Error when initialising electron App using electron-forge with electron-compile and electron-squirrel-startup 用Angular 5中的电子助剂构建电子应用 - Building Electron Application with electron-builder in Angular 5 使用VSCode调试电子锻造应用程序 - Debug electron-forge app with VSCode 如何分发使用电子构建器构建的构建可执行文件 - How to distribute a built executable constructed using electron-builder 使用电子伪造打包应用程序时出现问题“无法解析'./→'” - Problem while packaging application with electron-forge “Can't resolve './→' ” 使用电子锻造应用程序中的快递服务 static 文件 - Serve static files with express from within electron-forge app 无法在电子锻造应用程序中使用本机节点模块 - cannot use native node module in electron-forge app 在 Electron 应用程序中,使用 webpack/electron-builder 到 package 后,在 worker_threads 提示 MODULE_NOT_FOUND 中需要第三方模块 - In Electron app, after using webpack/electron-builder to package, require third-party module in worker_threads prompts MODULE_NOT_FOUND 使用电子生成器将文件夹和其中的文件包含到电子构建中? - Include a folder and the files inside it to electron build using electron-builder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM