detect-environment
Version:
Detect environments in JavaScript similar to the way Laravel does
57 lines (41 loc) • 1.8 kB
Markdown
base* environment. The base
environment is one which considered *production ready*. By default the `detect
environment` package sets this value to `production`.
Given the following input,
```sh
$ gulp foo --env=local
$ gulp foo --env=production
```
Above you can see a demonstration of `base` environment. When an environment
argument is passed in that matches the base environment name, the file to load
does not follow the traditional pattern of `.env.<envName>.yml` but instead it
just reverts to a simple `.env.yml`.
Taken from the [larvel configuration docs](http://laravel.com/docs/configuration#protecting-sensitive-configuration)
> Note: You may create a file for each environment supported by your
> application. For example, the development environment will load the
> .env.development.php file if it exists. However, the production environment
> always uses the .env.php file.
The difference with the `detect-environment` package is that you can specify the
name of the production environment by passing `{baseEnv: <name>}` to `de()`.
If the package detects that you are in the *base* environment it will set
`env.base` to `true`, otherwise it will be set to `false`.
The following two lines are the same.
```js
// Options 1
.pipe(gif(env.name === 'production', uglify()))
// Options 2
.pipe(gif(env.base, uglify()))
```
If you were to pass `{baseEnv: 'local'}` to `de()`, then the following would be
true.
```sh
$ gulp foo --env=local
$ gulp foo --env=production
```
It is not advised to change the `baseEnv` value, however under certain
circumstacnes it may be beneficial.
The `detect-environment` package has a concept of a *