@xailabs/app-config
Manage runtime and compile-time configs
Last updated 3 years ago by loopmode .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install @xailabs/app-config 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.5                                ...           latest (3 years ago)

6 Versions

  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |