@xailabs/app-config

1.0.5 • Public • Published

@xailabs/electron-config

A helper for managing electron app configuration at compile-time and runtime.

Documentation

Example usage in electron app:

~/Desktop/config.json

{
    "more": "stuff",
    "devstuff": {
        "development": "ok",
        "production": null
    }
}

src/config.js

export default {
    foo: 'foo',
    bar: {
        development: 'baz!!!',
        production: 'bar'
    }
};

src/main.js

import { app } from 'electron';
import { getConfig } from '@xailabs/app-config';
import defaultConfig from './config';

// take the config we have and extend it with values from the json file
const config = getConfig(defaultConfig, {
    
    // load this external file
    file: `${app.getPath('desktop')}/config.json`,  

    // if you find objects with `development` or `production` keys, resolve them
    resolve: process.env.NODE_ENV,                  

    // make the config read-only
    freeze: true                                    
});

console.log(config);

Resulting config in development build:

{
    foo: 'foo',
    bar: 'baz!!!',
    more: 'stuff',
    devstuff: 'ok'
}

Resulting config in production build:

{
    foo: 'foo',
    bar: 'bar',
    more: 'stuff',
    devstuff: null
}

Readme

Keywords

none

Package Sidebar

Install

npm i @xailabs/app-config

Weekly Downloads

0

Version

1.0.5

License

ISC

Last publish

Collaborators

  • b175h1f7
  • marius.nogueras
  • ius
  • loopmode
  • tkloht