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 r
Was running into issues with this as well, and found the files
property to be the solution. This particular example copies a directory from my node_modules
into the final build directory.
i.e. on Windows, it copies the files to: yourapp.exe/$PLUGINSDIR/app-64.7z/resources/app/
builder.config.js
module.exports = {
productName: "myapp",
appId: "com.reflex.app",
directories: {
output: "build",
},
files: [
"package.json",
{
// SOLUTION
from: "yourdirectoryorfilenamehere",
to: "yourdirectoryorfilenamehere",
filter: ["**/*"], // This will recursively include all sub-directories & files
},
],
// ... other configuration here ...
};
And then you can access the final files via a script in src/renderer/
or src/main
import { app } from "electron"; // For main process
/*
Or use this instead for the renderer process:
import { remote } from 'electron' // For renderer process
const { app } = remote
*/
const path = require("path");
const yourdirectoryorfilenamehere = path.join(app.getAppPath(), "/yourdirectoryorfilenamehere");
console.log(yourdirectoryorfilenamehere) // When built, this will show the path to where all your resources from (`files: []`) were saved