Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with dynamic references to env vars #115

Closed
you-fail-me opened this issue Mar 7, 2018 · 2 comments
Closed

Doesn't work with dynamic references to env vars #115

you-fail-me opened this issue Mar 7, 2018 · 2 comments

Comments

@you-fail-me
Copy link

you-fail-me commented Mar 7, 2018

Sample code:

const requiredEnv = [ 'VAR', 'ANOTHER_VAR' ];
const missingEnv = requiredEnv.filter(v => !process.env[v]);

This breaks with dotenv-webpack, seems like it handles only direct references well (like process.env.MY_VAR, but not dynamic ones, because does a text replace.

Is there a way around it?

@mrsteele
Copy link
Owner

mrsteele commented Mar 7, 2018

This is correct as we use webpack.DefinePlugin under the hood. Because of this is essentially does an advanced "search and replace" for any references to process.env.VAR.

We have explored resolving other issues related to this as well (see #70 (comment)).

For right now to maintain extensibility with future webpack upgrades I do not see any way around this. Should webpack eventually change how DefinePlugin works we would of course have those ready to use immediately without any updates.

If you have any ideas though I would be more than happy to hear them and consider exploring them.

I will leave this open temporarily until we have an appropriate answer.

@mrsteele
Copy link
Owner

I'm closing this as it is a duplicate of #70. Feel free to keep the conversation going over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants