npm

Need private packages and team management tools?Check out npm Orgs. »

@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
}

Keywords

none

install

npm i @xailabs/app-config

Downloadsweekly downloads

0

version

1.0.5

license

ISC

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability