美文网首页Web前端之路
electron-builder windows 和 linux

electron-builder windows 和 linux

作者: oNexiaoyao | 来源:发表于2020-06-06 21:33 被阅读0次
  • 使用的配置

    {
        "name": "web",
        "version": "1.8.0",
        "private": true,
        "homepage": "./",
        "main": "main.js",
        "scripts": {
            "serve": "vue-cli-service serve --open",
            "start": "yarn serve",
            "build": "vue-cli-service build",
            "electron-start": "electron .",
            "package": "electron-builder --publish never --win",
            "package:linux": "electron-builder --publish never --linux",
            "dev": "concurrently \"wait-on http://localhost:8080 && electron .\" \"cross-env BROWSER=none yarn start\""
        },
        "dependencies": {},
        "devDependencies": {
            "electron": "^8.2.1",
            "electron-builder": "21.2.0"
        },
        "build": {
            "appId": "Electron-desktop",
            "productName": "Electron-desktop",
            "copyright": "",
            "directories": {
                "output": "build"
            },
            "win": {
                "target": [
                    "nsis"
                ],
                "icon": "./dist/image/GuangFu.ico"
            },
            "linux": {
                "target": [
                    "AppImage"
                ]
            },
            "extends": null,
            "asar": true,
            "nsis": {
                "oneClick": false,
                "allowToChangeInstallationDirectory": true,
                "installerHeaderIcon": "./dist/image/HDLogo.ico",
                "installerIcon": "./dist/image/HuoDian.ico",
                "createDesktopShortcut": true
            }
        }
    }
    
    
  • vue/react 项目桌面端

    打包的流程是先将项目编译成生产版本,然后将打包后的生产版本再打包成桌面客户端

  • 遇到问题及解决方法

    • 项目路径含有中文字符,打包失败

      electron-builder-err2_LI.jpg
    • 在 windows 平台上打包 linux 失败,将项目迁移到 linux 环境上打包是成功

    • electron 打包太慢

      打包过程需要下载相应的文件导致,可以提前下载好对应的文件并存到对应的位置中。参考

相关文章

网友评论

    本文标题:electron-builder windows 和 linux

    本文链接:https://www.haomeiwen.com/subject/xmowzhtx.html