如何在Electron-Builder中使用Electron-Forge Typescript + webpack插件

ghhaqwfi  于 2023-11-15  发布在  Electron
关注(0)|答案(2)|浏览(203)

我做了什么-我使用electron forge typescript & webpack模板.另外,我想使用electron-builder而不是Electron-Forge windows maker windows.squirell,因为nsis打包选项.
错误-应用程序在开发模式下正常运行。但是,在打包的应用程序中,我得到一个白色屏幕。

怀疑构建器没有使用"@electron-forge/plugin-webpack"生成的构建文件
x1c 0d1x的数据

电建配置

"build": {
    "appId": "cloudapp",
    "win": {
      "target": [
        "nsis"
      ],
      "icon": "./src/images/cloudappLogo Icon.ico",
      "requestedExecutionLevel": "requireAdministrator"
    },
    "nsis": {
      "installerIcon": "./src/images/cloudappIcon.ico",
      "uninstallerIcon": "./src/images/cloudappLogo Icon.ico",
      "uninstallDisplayName": "cloudapp",
      "license": "license.txt",
      "oneClick": false,
      "allowToChangeInstallationDirectory": true
    }
  },

字符串

电子锻造配置

"config": {
    "forge": {
      "plugins": [
        [
          "@electron-forge/plugin-webpack",
          {
            "mainConfig": "./webpack/webpack.main.config.js",
            "renderer": {
              "config": "./webpack/webpack.renderer.config.js",
              "entryPoints": [
                {
                  "html": "./public/index.html",
                  "js": "./src/index.tsx",
                  "name": "main_window",
                  "preload": {
                    "js": "./electron/bridge.ts"
                  }
                }
              ]
            }
          }
        ]
      ]
    }
  },

e0uiprwp

e0uiprwp1#

我不得不使用Electron Forge打包我的文件,并在打包应用程序后使用Electron-Builder构建安装程序。

anauzrmj

anauzrmj2#

我使用以下步骤解决了它:
1.安装https://github.com/imxeno/electron-forge-maker-nsis
npm i @imxeno/electron-forge-maker-nsis
forge.config.ts,添加到makers数组:

{
  name: '@imxeno/electron-forge-maker-nsis',
  config: {}
},

字符串
创建electron-builder.js:

exports.default = function () {
  return {
    "productName": "...",
    "appId": "...",
    "nsis": {
        "oneClick": false,
        "runAfterFinish": true,
        ...
  }
};


}
运行npm run publish

相关问题