Related:
- https://github.com/meteor/meteor/issues/11287
- how to use environment variable in client and server at the very beginning
I'm also aware of METEOR_SETTINGS.
I have a Meteor app that will be deployed for different clients with different theming/features. I want to use an env variable such as process.env.CLIENT and have code like if(process.env.CLIENT === 'foo'). During build the env variable should be replaced and dead code elimination will remove/strip the if-block. This already works with NODE_ENV.
I don't want to ship code that a certain client does not need and I also don't want to implicitly expose the list of other clients. Both these things would happen if I check Meteor.settings at runtime. I need this to happen at compile time. Each client gets a different build.
How do I get environment variables through to the client? How are others solving this? process.env on the client currently is:
{"NODE_ENV":"development","TEST_METADATA":"{}"}
In other build tools I can either access all env variables on the client or those with a special prefix (for security reasons) like FOO_.