I've rigged create-react-app with the electron-forge app and now I need to somehow specify the build folder produced from the CRA for the packaging. That folder should also be served.
Would such a thing be possible with electron-forge?
I've rigged create-react-app with the electron-forge app and now I need to somehow specify the build folder produced from the CRA for the packaging. That folder should also be served.
Would such a thing be possible with electron-forge?
I understand are you asking how to tell electron-forge which directory to find your source files in for packaging the app.
If so, see: https://github.com/electron-userland/electron-packager/blob/master/docs/api.md
where it describes the options of the
"config": {
"forge": {
object in your package.json file
inside they there is this package config object:
"electronPackagerConfig": {
"dir": "./src",
where you can specify your source folder.
Also, BTW: there you can specify files/file-regexs to be ignored in packaging:
"ignore": [".idea", ".gitignore"]
electron-forge has no option to specify input folder (project's root folder will be used):
ignore
option to skip folders/files;main
key in
package.json to specify correct start script.For example, package.json for vue project:
{
"name": "project",
"version": "1.0.0",
"main": "index.js",
...
"config": {
"forge": {
"packagerConfig": {
"ignore": [
"^/[.]vs$",
"^/public$",
"^/src$",
"^/[.]browserslistrc$",
"^/[.]editorconfig$",
"^/tsconfig[.]json$",
"[.](cmd|user|DotSettings|njsproj|sln)$"
]
},
...
}
},
...
}
Actually you could specify source folder in script's arg only (assume /src is the folder with files to package):
electron-forge package ./src
That source folder must contain package.json with data electron-forge need to package your project. If no package.json will be found or it will not meet the requirements, electron-forge will go up to folder with proper package.json and assume it's the actual project folder. As I found in electron-forge sources, it needs at least this data:
{
name: cfg.name,
version: cfg.version,
author: cfg.author,
main: "main.js",
devDependencies: {
electron: cfg.devDependencies.electron,
"@electron-forge/cli": cfg.devDependencies["@electron-forge/cli"]
},
config: {
forge: "../forge.config.js"
}
}
In my project I create this package.json by script and use my main package.json as cfg
in sample above to provide data. Also you could provide forge config as a path to your forge.config.js to avoid of duplicate it.
Also keep in mind electron-forge would package files/dirs in that folder only, so neither node_modules nor other external assets will be included. Therefore you need either make bundle of your project with webpack, esbundle etc. or be careful with dependencies and provide it for packaged app.