I have a Node.JS v8.11.1 app running on an Ubuntu 14.04 LTS box. The app serves up AngularJS Javascript files and the HTML files that use them. I want to have a string value injected into one of the Javascript files that is sourced from an environment variable on the server, before I send the Javascript file to the client (i.e. - user's browser).
I know I can access the environment variables on the server side using "process.env.{environment.variable name}". What I need to know is how to take that value, inject it into my Javascript file so that when the Javascript file executes on the client side it has the desired string in its code. For example:
Environment variable on server side:
SOME_ENV_VAR=12345
Javascript statement in source file on server side:
var someVar = "REPLACE ME AT RUNTIME";
Javascript statement in source file by the time it reaches the client side:
var someVar = "12345";
How should I do this? Should I use a templating engine like Jade/Pug? Is that overkill?