# vue-human-env

> Vue human environment variables

Latest version **2.0.2** (published 2017-03-08) · 0 weekly downloads

## Install

```sh
npm install vue-human-env
pnpm add vue-human-env
yarn add vue-human-env
bun add vue-human-env
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2017-03-08 |
| First published | 2016-11-18 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | ChaselWu |
| Maintainers | vitualreaty |

## Links

- npm: https://www.npmjs.com/package/vue-human-env
- npm.io page: https://npm.io/package/vue-human-env

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^2.0.1

## Recent versions

- 2.0.2 (latest) — 2017-03-08
- 2.0.1 — 2016-11-18
- 2.0.0 — 2016-11-18

## README

<p align="center"><img width="320" src="docs/assets/vue-human.jpg"></p>

# vue-human-env

> vue-human-env 2.0.2

`vue-human-env` is a object to save your application environment variables.
And you can get some value from it.

> Just support vue2

# Install

Step 1: In your terminal

``` javascript
$ yarn add vue-human-env // or using `npm install`
```

Step 2: Must set babel in your webpack

``` javascript
loaders: [
  // Other loaders
  {
    test: /vue-human-env\/.*?js$/,
    loader: 'babel'
  }
]
```

Step 3: In your application, create src/env/index.js file

``` javascript
// src/env/index.js
import Vue from 'vue'
import VueHumanEnv from 'vue-human-env'
import config from './config.js'
import configLocal from './config.local.js'  // Copy from config.js, to save local config

Vue.use(VueHumanEnv, config, configLocal)

export default VueHumanEnv
```

Step 4: And then import env in your main.js

``` javascript
import Vue from 'vue'
import env from './env'

new Vue({
  // el....
  // store,
  // router,
  env
})
```

# Usage

### Method one

``` javascript
import Vue from 'vue'

Vue.env.get('APP_DEBUG')
```

### Method two
``` javascript
// in Vue component
{
  mounted () {
    this.$env.get('APP_DEBUG')
  }
}
```

### Method three

``` javascript
import env from '/src/some/path/env'

env.get('APP_DEBUG')
```

# Methods

``` javascript
// Simply get method
env.get('APP_DEBUG')

// Using dot to get nested object
env.get('MAIL.MAIL_PORT')
```

# How to define a config.js

``` javascript
export {
  APP_DEBUG: true,
  APP_NAME: 'Vue Env library',
  // Nested object
  MAIL: {
    MAIL_PORT: 900
  }
}
```

# Contributing

``` bash
// install dependencies
$ yarn install

// serve with hot reload at localhost:8080
$ npm run dev

// build this library
$ npm run build
```

---
_Source: https://npm.io/package/vue-human-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
