1.0.1 • Published 7 years ago
@wessberg/environment v1.0.1
Environment
Environment variables for all environments.
Installation
Simply do: npm install @wessberg/environment
.
Usage (with rollup)
Make sure to install the rollup plugin rollup-plugin-environment and add it to your rollup configuration:
rollup({
plugins: [
Environment(),
// Other plugins goes here...
]
});
This will just add a shim for the process
object in top of the bundle, reflecting the environment set up by this package.
Usage (in your code)
import {Config, Environment, EnvironmentKind} from "@wessberg/environment";
if (Config.DEBUG) {
// Do debug stuff here
}
if (Config.PRODUCTION) {
// Do production stuff here
}
// Switch through the kinds of environments.
switch (Environment.KIND) {
case EnvironmentKind.PRODUCTION:
case EnvironmentKind.STAGING:
// do stuff
break;
default:
// do other stuff
break;
}
Changelog:
v1.0.1:
- Added a strict-boolean check for process.env variables.
v1.0.0:
- First release.