web-dev-qa-db-ja.com

Electron AppをWindowsポータブルに切り替えようとしています

私は多くのことを検索しましたが、アプリをポータブルとして構築するのに実際に役立ったものはありません。私がいつもやっていることは問題ではなく、結果はnsisです。

Package.jsonに従います。

  {
  "name": "pvmplayer",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "postinstall": "install-app-deps",
    "start": "npm install && electron .",
    "pack": "build --dir",
    "dist": "build"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "ajv": "^6.5.1",
    "electron": "^2.0.2",
    "electron-builder": "^20.15.1"
  },
  "optionalDependencies": {},
  "dependencies": {},
  "electronBuilder": {
    "build": {
      "productName": "PVM Player",
      "appId": "scripter.PVMplayer",
      "win": {
        "target": ["portable"]
      },
      "directories": {
        "output": "electron/output",
        "app": "electron/app",
        "buildResources": "electron/buildResources"
      }
    }
  }
}

従うべき良いガイドはありますか?

これを試してください、移植可能なファイルはpvmplayer_portable.exeとして作成されます:

{
    "name": "pvmplayer",
    "version": "1.0.0",
    "description": "",
    "main": "main.js",
    "scripts": {
        "postinstall": "install-app-deps",
        "start": "npm install && electron .",
        "pack": "build --dir",
        "dist": "build"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "ajv": "^6.5.1",
        "electron": "^2.0.2",
        "electron-builder": "^20.15.1"
    },
    "optionalDependencies": {},
    "dependencies": {},
    "build": {
        "productName": "PVM Player",
        "appId": "scripter.PVMplayer",
        "win": {
            "target": ["portable"]
        },
        "portable": {
            "artifactName": "pvmplayer_portable.exe"
        },
        "directories": {
            "output": "electron/output",
            "app": "electron/app",
            "buildResources": "electron/buildResources"
        }
    }
}
8
Hai Pham