@electrojs/config
v1.0.8
Published
Typed config helpers for ElectroJS runtime and renderer view packages
Maintainers
Readme
@electrojs/config
Typed configuration contracts for ElectroJS applications.
Documentation: https://electrojs.myraxbyte.dev/
ElectroJS supports a monorepo-style application layout with:
- one root
electro.config.ts - one
runtime/package withruntime.config.ts - one package per renderer view with
view.config.ts
Installation
pnpm add -D @electrojs/config vite typescriptExports
import { defineElectroConfig, defineRuntimeConfig, defineViewConfig } from "@electrojs/config";
import type { AppConfig, RuntimeConfig, ViewConfig } from "@electrojs/config";electro.config.ts
import { defineElectroConfig } from "@electrojs/config";
export default defineElectroConfig({
runtime: "runtime",
views: ["@views/main", "@views/settings"],
});AppConfig:
interface AppConfig {
readonly runtime: string;
readonly views: readonly string[];
}runtimeis the package specifier for the runtime packageviewsis the explicit list of renderer view package specifiers
ElectroJS documents explicit package configuration as the supported setup instead of single-repo auto-discovery.
runtime.config.ts
import { defineRuntimeConfig } from "@electrojs/config";
export default defineRuntimeConfig({
entry: "./src/main.ts",
});RuntimeConfig extends Vite user config and adds:
interface RuntimeConfig extends ViteUserConfig {
readonly entry: string;
}entrypoints at the Electron main-process entry file inside the runtime package
view.config.ts
import { defineViewConfig } from "@electrojs/config";
import react from "@vitejs/plugin-react";
export default defineViewConfig({
viewId: "main",
entry: "./index.html",
plugins: [react()],
});ViewConfig extends Vite user config and adds:
interface ViewConfig extends ViteUserConfig {
readonly viewId: string;
readonly entry?: string;
readonly preload?: string;
}viewIdis the bundled renderer id used by runtime@View({ source: "view:<id>" })entrydefaults to./index.htmlpreloadis optional because ElectroJS usually generates preload entrypoints automatically
Layout
my-app/
├── electro.config.ts
├── pnpm-workspace.yaml
├── package.json
├── runtime/
│ ├── runtime.config.ts
│ └── src/main.ts
└── views/
├── main/
│ ├── view.config.ts
│ ├── index.html
│ └── src/main.tsx
└── settings/Related Packages
@electrojs/clirunsdev,generate,build, andpreview@electrojs/runtimepowers the Electron runtime@electrojs/rendererpowers the renderer bridge and signals APIs
