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
merged 2 commits into from Jun 25, 2021

Conversation

shilman
Copy link
Member

@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

@nx-cloud
Copy link

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.

@nx-cloud
Copy link

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 June 25, 2021 13:01
import path from 'path';

// https://github.com/mrsteele/dotenv-webpack/blob/master/src/index.js#L34
const DOTENV_FILE = path.join('.', '.env');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@shilman shilman deleted the 14257-conditional-dotenv branch June 25, 2021 15:23
@shilman shilman added patch:yes Bugfix & documentation PR that need to be picked to main branch patch:done Patch/release PRs already cherry-picked to main/release branch labels Jun 28, 2021
shilman added a commit that referenced this pull request 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
Labels
bug builder-webpack5 core patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants