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

Core: Only use dotenv-webpack when a user has a dotenv file #15365

merged 2 commits into from Jun 25, 2021


Copy link

@shilman shilman commented Jun 25, 2021

Issue: #14257

What I did

Get rid of webpack5 warning when dotenv-webpack's process.env definition conflicts with our own DefinePlugin usage by simply not using the plugin unless the user has a .env file in the current directory.

This was not a problem in Webpack4, but has gotten more strict in Webpack5.

This PR does not solve the problem where users DO have a .env file, but it should remove spurious warnings for users that DON'T.

How to test

Not easy to test in the current monorepo setup because we cannot run webpack5

Copy link

@nx-cloud nx-cloud bot commented Jun 25, 2021

Nx Cloud Report

CI ran the following commands for commit 1aca2f1. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

Copy link

@nx-cloud nx-cloud bot commented Jun 25, 2021

Nx Cloud Report

We didn't find any information for the current pull request with the commit 2d4f2f5.
Please make sure you set the \ NX_BRANCH\ environment variable in your CI pipeline .

Check the Getting started section to configure the app.

Sent with 💌 from NxCloud.

@shilman shilman requested a review from ndelangen Jun 25, 2021
import path from 'path';

const DOTENV_FILE = path.join('.', '.env');
Copy link

@ndelangen ndelangen Jun 25, 2021

Aren't some people defining special environment specific .env files which get auto-loaded?

.prod.env etc?

Copy link
Member Author

@shilman shilman Jun 25, 2021

Not in our current setup. dotenv-webpack has options to support that, but we don't pass those options in.

@shilman shilman merged commit 1db1627 into next Jun 25, 2021
37 of 41 checks passed
@shilman shilman deleted the 14257-conditional-dotenv branch Jun 25, 2021
shilman added a commit that referenced this issue Jun 28, 2021
Core: Only use dotenv-webpack when a user has a dotenv file
@shilman shilman added this to the 6.4 PRs milestone Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants