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

docs(plugins): update EnvironmentPlugin warning #7461

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

snitin315
Copy link
Member

Fix #7448

Copy link

vercel bot commented Nov 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
webpack-js-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2024 2:31pm

@snitin315 snitin315 merged commit 6fe45e5 into main Nov 5, 2024
8 checks passed
@snitin315 snitin315 deleted the fix-env-plugin-warning branch November 5, 2024 02:50
@fasiha
Copy link

fasiha commented Nov 5, 2024

I was hoping that this PR would include a note about the issue raised in #7448 where, if you use process.env.SOMETHING and that EnvironmentPlugin doesn't know about it, Webpack will happily ignore process.env.SOMETHING and include it in the output.

@snitin315
Copy link
Member Author

EnvironmentPlugin checks process.env for the specified variable.

@fasiha This is mentioned in the warning EnvironmentPlugin checks only for the variables specified within this plugin. Otherwise, no errors.

@fasiha
Copy link

fasiha commented Nov 6, 2024

@snitin315 thanks for the note! Do you mean this warning?:

W> EnvironmentPlugin checks process.env for the specified variable. If it’s missing, it searches for a default value provided in the configuration. If neither the environment variable nor the default value is defined, an error will be thrown: "EnvironmentPlugin - ${key} environment variable is undefined".

Re-reading this, I don't think it makes clear that the plugin ignores usages of process.env that it doesn't know about? So perhaps we could add a line to this paragraph, something like what you said:

EnvironmentPlugin checks only for variables specified by this plugin. Using process.env with unspecified variables results in those usages being ignored: for example, process.env.UNKNOWN will be left intact.

@snitin315
Copy link
Member Author

@fasiha sure, feel free to send a PR

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

Successfully merging this pull request may close these issues.

EnvironmentPlugin doesn't error if environment variable wasn't found?
2 participants