How do I reference config/environment.js in a plain old JS file?


The Guide provides an example in ES6 for reading variables out of the environment.js file:

However, I want to use one of the values in ENV.APP in a plain old .js file. Specifically, I want to dynamically set an http-proxy target server depending on the environment.

In /server/proxies/api.js I added this code at the top:

var proxyConfig = require('./../../config/environment.js');
console.log( 'Proxy Config: ' + JSON.stringify(proxyConfig, null, 2) );

I get this as the output:

Proxy Config: undefined

How can I access ENV.APP settings in regular JavaScript files?


Not sure you should do it like this but you can write:

document.querySelector('meta[name="myapp/config/environment"]').setAttribute("content", _desc);

for view-source: