Skip to content

Expose Node.js global process.env to compiled client-side code

Notifications You must be signed in to change notification settings

jasonkuhrt-archive/duo-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duo-env build status

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 to require(NAME). Defaults to "env".
  • pick – expose only a subset of process.env. The exposed module is still a hash, but does not include the huge amount of things that process.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: duojs/duo#362

About

Expose Node.js global process.env to compiled client-side code

Resources

Stars

Watchers

Forks

Packages

No packages published