如何使用电子生成器将文件夹和文件添加到电子构建

How to add folders and files to electron build using electron-builder(如何使用电子生成器将文件夹和文件添加到电子构建)
本文介绍了如何使用电子生成器将文件夹和文件添加到电子构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在创建一个运行从 create-react-app 生成的反应的电子.然后我添加 nedbjs(一个持久性数据库)和 camojs(用于 nedb 的 ODM)作为依赖项.要与 nedb 连接反应,我使用电子 ipc.

I am creating an electron which running react generated from create-react-app. Then i add nedbjs(a persistence database) and camojs(ODM for nedb) as dependency. To connect react with nedb i use electron ipc.

这是我的项目结构:

这是我的 package.json:

And here is my package.json:

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "electron-dev": "concurrently "cross-env BROWSER=none yarn start" "wait-on http://localhost:3000 && electron ."",
    "electron-pack": "build --em.main=build/electron.js",
    "electron-release": "build --em.main=build/electron.js --publish=always",
    "preelectron-pack": "yarn build",
    "preelectron-release": "yarn build"
  },
  "build": {
    "appId": "com.example.cra-electron-boilerplate",
    "files": [
      "build/**/*",
      "node_modules/**/*",
      "package.json"
    ],
    "directories": {
      "buildResources": "assets"
    },
    "publish": {
      "provider": "github"
    }
  },

我使用命令 yarn electron-pack 来打包我的应用程序.然后从 dist 文件夹运行解压后的可执行文件然后得到这个错误:

I use command yarn electron-pack to package my app. And then running the unpacked executable from dist folder then got this error:

这里是 我的仓库

推荐答案

要在您的电子构建文件夹中添加文件或文件夹,您可以在 package.json 中添加 extraFiles 选项.这是一个复制凭据"目录的示例:

To add a file or folder on your electron build folder, you can add the extraFiles options on package.json. Here is an example to copy a "credential" directory:

"build": {
  "appId": "com.example.electron-boilerplate",
  "files": [
    "app/**/*",
    "node_modules/**/*",
    "package.json"
  ],
  "directories": {
    "buildResources": "resources"
  },
  "extraFiles": [
    "credentials"
  ],
  "publish": null
},

然后

$ npm run release // as usual

希望对你有帮助

这篇关于如何使用电子生成器将文件夹和文件添加到电子构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Google apps script get range of bytes from binary file(谷歌应用程序脚本从二进制文件中获取字节范围)
Sending Multiple attachments with Google Script from Google Drive(使用 Google 脚本从 Google Drive 发送多个附件)
Distributing Google Apps Scripts for Sheets in your company network(在您的公司网络中分发适用于表格的 Google Apps 脚本)
Upload file to my google drive from anyone using javascript(使用 javascript 将文件从任何人上传到我的谷歌驱动器)
quot;Shared Drivequot; support in Google Apps Script(“共享驱动器Google Apps 脚本中的支持)
Angular 2+ HTTP POST and GDrive API. Resumable file upload with name(Angular 2+ HTTP POST 和 GDrive API.带名称的可恢复文件上传)