-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow dynamic specification of "main"
field in package.json
#270
Comments
"main"
Field in package.json
"main"
field in package.json
This commit makes the build process more robust, simplifies configurations and reduce the risk of incomplete or erroneous deployments. - Centralize output directory definitions by introducing `dist-dirs.json`. - Add `verify-build-artifacts` utility to ensure correct build outputs and `print-dist-dir` to determine distribution directory. - Add steps in CI/CD pipeline to verify build artifacts. - Migrate Electron Builder config from YAML to CJS for capability to read JSON. - Fix `release-site.yaml` failing due to pointing to wrong distribution directory, change it to use `print-dist-dir`. - Improve `check-desktop-runtime-errors` to verify build artifacts for more reliable builds. Ensure tests fail and succeed reliably. - Update `.gitignore` and configure ESLint to use it to define and ignore build artifact directories from one place, remove `.eslintignore` that does not add anything after this change. - Keep `"main"` field in `package.json` as `electron-vite` depends on it (alex8088/electron-vite#270). - Improve documentation
Maybe adding a electron-vite dev --entry out/main/xxx.js |
Thanks for the quick response @alex8088 . Config file option would simplify my setup with power of TypeScript but this can be only specific to me. CLI option would still solve it for me but I will need to build some cross-platform command wrappers so I can read distribution directory from JSON file. Even though I prefer config file option if I had the choice, CLI option would be much appreciated (it should work with Out-of-topic appreciation/feedbackI really like how clean your code is here. I also see perfect balance of the project where it just does enough "magic" that eliminates common problems without abstracting too much. I decided on this when I was doing deep dive through lack of ESM support in electron and got it working with completely different and much simpler config than provided there. I recommend the plugin to all I know how much effort it takes to maintain open-source, often with little to no gains. Your efforts are appreciated 👍️. |
This feature should be added in the next version, and of course it will support all CLI commands. Thank you for your appreciation and recommendation for this project. Providing faster and cleaner DX for Electron was the motivation behind this project. It's great to help Electron developers solve some difficult problems. |
This commit refactors configuration to use centrally defined Electron entry file path to improve maintainability and reduce duplication. - Replace the hardcoded file path in the `main` field of `package.json` with a reference to the `ELECTRON_ENTRY` environment variable, managed by `electron-vite`. - Update `electron-vite` to version 1.0.28, enabling the use of `ELECTRON_ENTRY` environment variable feature (details in alex8088/electron-vite#270).
Works great, environment variable was a life saver, thank you for listening, your efforts and quick action @alex8088 👍️ |
This commit refactors configuration to use centrally defined Electron entry file path to improve maintainability and reduce duplication. - Replace the hardcoded file path in the `main` field of `package.json` with a reference to the `ELECTRON_ENTRY` environment variable, managed by `electron-vite`. - Update `electron-vite` to version 1.0.28, enabling the use of `ELECTRON_ENTRY` environment variable feature (details in alex8088/electron-vite#270).
This commit makes the build process more robust, simplifies configurations and reduce the risk of incomplete or erroneous deployments. - Centralize output directory definitions by introducing `dist-dirs.json`. - Add `verify-build-artifacts` utility to ensure correct build outputs and `print-dist-dir` to determine distribution directory. - Add steps in CI/CD pipeline to verify build artifacts. - Migrate Electron Builder config from YAML to CJS for capability to read JSON. - Fix `release-site.yaml` failing due to pointing to wrong distribution directory, change it to use `print-dist-dir`. - Improve `check-desktop-runtime-errors` to verify build artifacts for more reliable builds. Ensure tests fail and succeed reliably. - Update `.gitignore` and configure ESLint to use it to define and ignore build artifact directories from one place, remove `.eslintignore` that does not add anything after this change. - Keep `"main"` field in `package.json` as `electron-vite` depends on it (alex8088/electron-vite#270). - Improve documentation
This commit refactors configuration to use centrally defined Electron entry file path to improve maintainability and reduce duplication. - Replace the hardcoded file path in the `main` field of `package.json` with a reference to the `ELECTRON_ENTRY` environment variable, managed by `electron-vite`. - Update `electron-vite` to version 1.0.28, enabling the use of `ELECTRON_ENTRY` environment variable feature (details in alex8088/electron-vite#270).
Clear and concise description of the problem
As a developer using
electron-vite
, I would like the ability to dynamically set the"main"
field inpackage.json
or haveelectron-vite
handle this automatically. This will make the build process more flexible and centralized.Take
electron-builder
for instance, which allows us to dynamically set the"main"
field:This functionality allows for centralized management of distribution directories, which is crucial for complex projects. In contrast,
package.json
forces us to hardcode this information, which limits flexibility.Suggested solution
Alternative 1:
electron-vite
already knows the main entry file's location and where to copy it. Can it patchpackage.json
or implement a similar mechanism to point to the main file from the distribution directory? This would enable a zero-config approach.Alternative 2:
Allow developers to specify the main file path in one of the configuration files. This could even be an additional feature on top of Alternative 1.
Alternative
No response
Additional context
First of all, thank you for this excellent plugin. The TypeScript configuration files are a great help, and the support for ESM modules is impressive. The documentation is clear and comprehensive; I never had to look at the code. This project now empowers desktop builds of privacy.sexy.
What I'm trying to solve:
This need arose when I attempted to centralize all distribution directory configurations into a single
dist-dirs.json
file. The goal is to eliminate hardcoded paths that lead to unstable builds. While I can easily manage this inelectron.vite.config.ts
,electron-builder.cjs
,vite.config.ts
, or in CI/CD pipelines/other commands through a utility I build (scripts/print-dist-dir.js
), I cannot do so inpackage.json
. This issue aims to bridge that gap.Validations
The text was updated successfully, but these errors were encountered: