# ember-cli-global-env

> support global env const in js and hbs for ember app

Latest version **1.0.0** (published 2020-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-cli-global-env
pnpm add ember-cli-global-env
yarn add ember-cli-global-env
bun add ember-cli-global-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 | 1.0.0 |
| Published | 2020-04-26 |
| First published | 2020-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 10.* \|\| >= 12 |
| Dependencies | 6 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | houfeng0923@gmail.com |
| Maintainers | houfeng |
| Keywords | ember-addon, babel-plugin, template-plugin |

## Links

- npm: https://www.npmjs.com/package/ember-cli-global-env
- Repository: https://github.com/houfeng0923/ember-cli-global-env
- Homepage: https://github.com/houfeng0923/ember-cli-global-env#readme
- Issues: https://github.com/houfeng0923/ember-cli-global-env/issues
- npm.io page: https://npm.io/package/ember-cli-global-env

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^7.17.2
- [ember-cli-htmlbars](https://npm.io/package/ember-cli-htmlbars.md) ^4.2.2
- [babel-plugin-tester](https://npm.io/package/babel-plugin-tester.md) ^9.0.1
- [ember-template-lint](https://npm.io/package/ember-template-lint.md) ^2.4.0
- [ember-cli-babel-plugin-helpers](https://npm.io/package/ember-cli-babel-plugin-helpers.md) ^1.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-04-26
- 0.1.1 — 2020-04-23
- 0.1.0 — 2020-04-15
- 0.0.5 — 2020-04-14
- 0.0.4 — 2020-04-09
- 0.0.3 — 2020-04-09
- 0.0.2 — 2020-04-08
- 0.0.1 — 2020-04-08

## README

ember-cli-global-env
==============================================================================

support global env const in js and hbs for ember app.


Features
------------------------------------------------------------------------------

- support js and hbs files
- minify code in production mode



Compatibility
------------------------------------------------------------------------------

* Ember.js v3.2 or above
* Ember CLI v2.13 or above
* Node.js v10 or above


Installation
------------------------------------------------------------------------------

```
ember install ember-cli-global-env
```


Usage
------------------------------------------------------------------------------

By default, automatic import all `APP-*` variables in `process.env`, so you can use it directly;
otherwise, your can define extra const in `config/global-env.js`.

```js
// config/global-env.js

module.exports = function (environment) {
  const flags = {
    CFX: process.env['APP_BRAND'] === 'cfx',
    Token: 'xxxxx'
  };

  return flags;
};
```

Additional options can be specified using the `global-env` config property in `ember-cli-build.js`:

```js
let app = new EmberApp({
  'global-env': {...}
});
```

**Available Options:**

- `helperName`: default is **env**, a helper for access global env in template
- `importPath`: default is **@global/env**, so you can import global env from this path


Example
------------------------------------------------------------------------------

### hbs

source:

```hbs
{{env 'Token'}}

{{#if (env 'CFX')}}
  <div>cfx template....</div>
{{/if}}

{{other-component}}
```

output (in building before opcode) :

```hbs
xxxxxx

<div>cfx template....</div>

{{other-component}}
```

### js

source:

```js
import { CFX, Token } from '@global/env';

export default class IndexRoute extends Route {
  init() {
    console.log(Token);
    if (!CFX) {
      console.log('cfx logic');
    }
  }
}
```

output (in production mode)

```js
export default class IndexRoute extends Route {
  init() {
    console.log('xxxxxx');
  }
}
```

Contributing
------------------------------------------------------------------------------

See the [Contributing](CONTRIBUTING.md) guide for details.


License
------------------------------------------------------------------------------

This project is licensed under the [MIT License](LICENSE.md).

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