diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.js | 9 | ||||
| -rw-r--r-- | src/index.html | 12 | ||||
| -rw-r--r-- | src/index.js | 5 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..ef39548 --- /dev/null +++ b/src/config.js @@ -0,0 +1,9 @@ +const processEnv = typeof process !== 'undefined' ? process.env : {}; +const injectedEnv = window && window.injectedEnv ? window.injectedEnv : {}; + +const env = { + ...processEnv, + ...injectedEnv, +}; + +export { env }; diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..e7db26c --- /dev/null +++ b/src/index.html @@ -0,0 +1,12 @@ +<!doctype html> +<html lang="en"> + <head> + <title>Frontend demo with Nginx + environment variables</title> + <script src="/inject.js"></script> + </head> + <body> + <h1>Frontend demo with Nginx + environment variables</h1> + <div id="app"></div> + <script src="/app.js"></script> + </body> +</html> diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..b26e960 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +import { env } from './config'; + +Object.keys(env).forEach(key => { + document.getElementById('app').innerHTML += `<div>${key}: ${env[key]}</div>`; +}); |
