# @staticdeploy/app-config

> Configuration for static apps

Latest version **2.0.2** (published 2019-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @staticdeploy/app-config
pnpm add @staticdeploy/app-config
yarn add @staticdeploy/app-config
bun add @staticdeploy/app-config
```

Provides the commands `inject-config`, `dev-config-server`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2019-08-28 |
| First published | 2017-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Paolo Scanferla |
| Maintainers | davidebianchi, pscanf, staticdeploy-npm-bot |

## Links

- npm: https://www.npmjs.com/package/@staticdeploy/app-config
- Repository: https://github.com/staticdeploy/app-config
- Issues: https://github.com/staticdeploy/app-config/issues
- npm.io page: https://npm.io/package/@staticdeploy/app-config

## Dependencies (6)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [yargs](https://npm.io/package/yargs.md) ^14.0.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.3
- [express](https://npm.io/package/express.md) ^4.17.1

## Recent versions

- 2.0.2 (latest) — 2019-08-28
- 2.0.1 — 2018-06-19
- 2.0.0 — 2017-12-30
- 1.0.0 — 2017-11-08

## README

[![npm version](https://img.shields.io/npm/v/@staticdeploy/app-config.svg)](https://www.npmjs.com/package/@staticdeploy/app-config)
[![build status](https://img.shields.io/circleci/project/github/staticdeploy/app-config.svg)](https://circleci.com/gh/staticdeploy/app-config)
[![coverage status](https://codecov.io/github/staticdeploy/app-config/coverage.svg?branch=master)](https://codecov.io/github/staticdeploy/app-config?branch=master)
[![dependency status](https://david-dm.org/staticdeploy/app-config.svg)](https://david-dm.org/staticdeploy/app-config)
[![devDependency status](https://david-dm.org/staticdeploy/app-config/dev-status.svg)](https://david-dm.org/staticdeploy/app-config#info=devDependencies)

# app-config

A tool for generating configuration files for static apps.

### Install

```
yarn add @staticdeploy/app-config
```

### Quickstart

- add the following `<script>` to your `public/index.html`:

  ```html
  <script id="app-config" src="http://localhost:3456/app-config.js"></script>
  ```

- access the config variable in your code:
  ```js
  console.log(window.APP_CONFIG.MY_VAR);
  ```

Then:

#### In development

- define configuration in the `.env` file:

  ```sh
  APP_CONFIG_MY_VAR=my_val
  ```

- start the development server with `$(npm bin)/dev-config-server`

#### In production

- build your app and get the path of the app's `index.html` (for example, for
  apps built with
  [create-react-app](https://github.com/facebookincubator/create-react-app) the
  path is `build/index.html`)

- defining configuration via environment variables:

  ```sh
  export APP_CONFIG_MY_VAR=my_val
  ```

- inject the configuration into the index file by running:
  ```sh
  $(npm bin)/inject-config --file path/to/index.html
  ```

### Additional documentation

- [how `window.APP_CONFIG` is generated](docs/config-generation.md)
- [`inject-config` cli options](docs/inject-config-cli-options.md)
- [`dev-config-server` cli options](docs/dev-config-server-cli-options.md)

---
_Source: https://npm.io/package/@staticdeploy/app-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
