(十三) electron 应用打包

914 阅读1分钟

使用 electron-builder来打包应用。

安装

yarn add electron-builder --dev

修改package.json

{
    "scripts": {
        "dev": "node build/dev-runner",
        "start": "electron electron/main",
        "serve": "vue-cli-service serve",
        "build": "vue-cli-service build",
        "lint": "vue-cli-service lint",
        "pack": "electron-builder --dir",
        "dist": "electron-builder",
        "bd": "yarn build && electron-builder",
        "postinstall": "electron-builder install-app-deps"
    },
    "build": {
        "productName": "EBlog",
        "directories": {
            "output": "build/dist"
        },
        "files": [
            "dist/**/*",
            "electron/**/*"
        ],
        "extraResources": "public",
        "dmg": {
            "contents": [
                {
                    "x": 410,
                    "y": 150,
                    "type": "link",
                    "path": "/Applications"
                },
                {
                    "x": 130,
                    "y": 150,
                    "type": "file"
                }
            ]
        },
        "mac": {
            "icon": "build/icons/icon.icns"
        }
    }
}

运行

yarn bd

会在build/dist目录下生成对应包文件

博客地址: alibt.top

更多精彩,请关注我的公众号!