2.9.0-beta.1 • Published 11 months ago

@app-config/electron v2.9.0-beta.1

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
11 months ago

App Config Electron

Easily inject app-config values into Electron renderer processes. An example project is provided here.

Usage

1. Install App Config and the Electron Package

yarn add @app-config/main @app-config/electron

Or, if you use NPM.

npm i @app-config/main @app-config/electron

2. Load your config with any options you need in the main Electron process before creating any windows

app.whenReady().then(() => {
  loadConfig().then(() => {
    const mainWindow = new BrowserWindow();

    mainWindow.loadFile('./index.html')
  });
});

3. Insert the App Config preload script into your BrowserWindow webPreferences

Pass your config and optionally any other BrowserWindow webPreferences you need to addAppConfigPreload.

app.whenReady().then(() => {
  loadConfig().then(() => {
    const mainWindow = new BrowserWindow({
      webPreferences: addAppConfigPreload(config),
    });

    mainWindow.loadFile('./index.html')
  });
});

4. Your App Config values are now available!

They can be found in window._appConfig or in config if using @app-config/main in your web page (when using @app-config/webpack with headerInjection or @app-config/vite with readGlobal). It's also available in config in the main Electron process.

Your app will need to be restarted to reflect any configuration changes.

Setting contextIsolation to true in the browserOptions of your BrowserWindow settings is required for this package to work. We set this for you, but if your app requres contextIsolation to be false using this package will break your app.

2.9.0-beta.1

11 months ago

2.8.7

1 year ago

2.8.6

1 year ago

2.8.5

2 years ago

2.8.3

2 years ago

2.8.4

2 years ago

2.8.2

2 years ago

2.8.1

3 years ago

3.0.0-alpha.5

3 years ago

3.0.0-alpha.6

3 years ago

2.8.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago