Runtime env var support for static javascript apps on Heroku
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Preserve bundle size (#1) Oct 24, 2016
.gitignore 🌱 Oct 13, 2016
.travis.yml TravisCI Oct 16, 2016
LICENSE MIT license (#5) Oct 18, 2017
README.md 📚 link to experimental heroku-js-runtime-env-buildpack Sep 24, 2018
index.js Preserve bundle size (#1) Oct 24, 2016
package.json version 3.0.2 Oct 18, 2017

README.md

Heroku JS Runtime Env

Use runtime environment variables in bundled/minified javascript apps.

Build Status npm Module

Usage

Designed for create-react-app-buildpack. See its documentation to use this module for Runtime configuration.

See also 🔬🚧 experimental, generalized usage with heroku-js-runtime-env-buildpack.

Background

Normally javascript apps are compiled into a bundle before being deployed. During this build phase, environment variables may be embedded in the javascript bundle, such as with Webpack DefinePlugin.

When hosting on a 12-factor platform like Heroku, these embedded values may go stale when setting new config vars or promoting through a pipeline.

How Does It Work?

When developing your app, use Runtime environment variables from create-react-app-buildpack.

Then, each time the app starts-up on Heroku, a .profile.d script (installed from the buildpack) is executed which fills in a JSON placeholder in the JavaScript bundle with the runtime environment variables. The result is 🍃fresh runtime environment variables in the production javascript bundle without recompiling.