duo-env
v0.0.4
Published
Expose Node.js global process.env to compiled client-side code
Downloads
4
Maintainers
Readme
duo-env
Expose Node.js global process.env to compiled client-side code
Installation
$ npm install --save duo-env
Example
// file: app.js
var env = require('env').NODE_ENV
var uri = env === 'prod' ? 'api.foobar.io' : 'localhost:8000'
// ...
NODE_ENV=prod duo app.js > build/app.js --use duo-env
# Now "uri" in compiled app will equal 'api.foobar.io'
API
The following settings are available:
name
– the literal module name that will be exposed, eg: what you want torequire(NAME)
. Defaults to "env".pick
– expose only a subset ofprocess.env
. The exposed module is still a hash, but does not include the huge amount of things thatprocess.env
has even by default.
Currently these settings are only useable in a scripted duo context, but I want to make it possible to pass these on the CLI too: https://github.com/duojs/duo/issues/362