env-builder

Build environment variables with inheritance

Usage no npm install needed!

<script type="module">
  import envBuilder from 'https://cdn.skypack.dev/env-builder';
</script>

README

env-builder Build Status

Build environment variables with inheritance

Tests

$ npm test

Layout

.
├── default
│   ├── default
│   ├── test
│   └── local
├── types
│   ├── ui
│   │   ├── default
│   │   ├── test
│   │   └── local
│   ├── api
│   │   ├── default
│   │   ├── test
│   │   └── local
│   └── auth
│       ├── default
│       ├── test
│       └── local
└── apps
    ├── my-first-app
    │   ├── default
    │   ├── test
    │   └── local
    ├── my-second-app
    │   ├── default
    │   ├── test
    │   └── local
    └── my-third-app
        ├── default
        ├── test
        └── local
{
  default: {
    default: {
      API_URL: 'http://example.com'
    },
    test: {
      API_URL: 'http://test.example.com'
    },
    local: {
      API_URL: 'http://dev.example.com'
    }
  },
  types: {
    ui: {
      default: {
        NODE_ENV: 'production'
      },
      test: {
        NODE_ENV: 'test'
      },
      local: {
        NODE_ENV: 'development'
      }
    }
  },
  apps: {
    'my-first-app': {
      default: {
        APP_VAR: 'foo'
      },
      test: {
        APP_VAR: 'bar'
      },
      local: {
        APP_VAR: 'baz'
      }
    }
  }
}