2017-07-29 58 views
0

我正在創建一個運行從create-react-app生成的響應的電子。然後我添加nedbjs(一個持久性數據庫)和camojs(ODM for nedb)作爲依賴。連接反應與nedb我使用電子ipc。如何將文件夾和文件添加到使用電子構建器的電子版本中

這裏是我的項目結構:

enter image description here

這裏是我的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" 
    } 
    }, 

我用命令紗電子包裝來包裝我的應用程序。然後運行從DIST文件夾解壓的可執行文件,然後得到這個錯誤:

enter image description here

這裏是my repo

+0

你的IDE看上去很美 –

+0

@CommercialSuicide謝謝。它的Atom,安裝了文件圖標包。 –

回答

0

要增加你的電子版文件夾文件或文件夾,您可以在包中添加extraFiles選項以.json。 這裏是複製 「憑證」 目錄中的一個例子:

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

然後

$ npm run release // as usual 

希望這將有助於

相關問題