首页 > 解决方案 > 无法打包/构建 Electron Forge 应用程序以进行生产

问题描述

我正在通过 EF React 模板使用当前版本的 Electron Forge、React 等。当我运行使用packageor创建的可执行文件make(当前在 Windows 下进行测试,但在 OS X 下发生相同的行为)时,我收到未处理的错误“React 正在生产模式下运行”,这会停止应用程序(AFAICT)。

NODE_ENV=production在包装或制作之前尝试过设置,但并没有什么不同。这是股票EF。

开发部:

"electron-forge": "^5.2.4",
"electron-prebuilt-compile": "4.0.0",

部门:

"electron-compile": "^6.4.4",
"electron-debug": "^2.1.0",
"electron-devtools-installer": "^2.1.0",
"electron-squirrel-startup": "^1.0.0",
"react": "^16.4.1",

.compilerc

{
  "env": {
    "development": {
      "application/javascript": {
        "presets": [
          ["env", { "targets": { "electron": "1.6.0" } }],
          "react"
        ],

        "plugins": [
          "transform-decorators-legacy",
          "transform-class-properties",
          "transform-async-to-generator",
          "transform-es2015-classes",
          "transform-object-rest-spread",
          "react-hot-loader/babel",
          "babel-plugin-root-import"
        ],

        "sourceMaps": "inline"
      }
    },

    "production": {
      "application/javascript": {
        "presets": [
          ["env", { "targets": { "electron": "1.6.0" } }],
          "react"
        ],

        "plugins": [
          "transform-decorators-legacy",
          "transform-class-properties",
          "transform-async-to-generator",
          "transform-es2015-classes",
          "transform-object-rest-spread",
          "babel-plugin-root-import"
        ],

        "sourceMaps": "none"
      }
    }
  }
}

我可以提供任何其他需要的信息——这个问题让我很伤心。

标签: reactjselectronelectron-forge

解决方案


推荐阅读