1 stable release
1.0.1 | Feb 22, 2020 |
---|
#172 in #env
6KB
73 lines
env2js
Converts current env to js/json. Supports reading from .env
files.
Usage
All commands are available via env2js --help
>$ env2js --help
Converts your env to js or json file
USAGE:
env-to-json [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --config <FILE> Sets a custom env file [default: .env]
-g, --global <GLOBAL_VAR> Sets a custom global variable for javascript [default: __env]
-p, --prefix <PREFIX> Env variables prefix filter
-t, --type <TYPE> Set output type [default: js] [possible values: js, json]
You can use it for making env variables available in runtime of your react app.
>$ REACT_APP_FOO=bar env2js -g env -p REACT_APP_ -t js > env.js
Will result in following file:
window.env = {"FOO":"bar"}
Versions
Linux
- env2js - simple build, without size optimizations
- env2js.min - build with stripped symbols
- env2js.nano - packed build with upx (seems upx on ubuntu is kinda broken, so this binary may be broken too)
Windows
- env2js.exe - windows build
License
Dependencies
~1–1.5MB
~24K SLoC