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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/content/plugins/environment-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ new webpack.DefinePlugin({
});
```

T> Not specifying the environment variable raises an "`EnvironmentPlugin` - `${key}` environment variable is undefined" error.
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`"**.

## Usage with default values

Expand All @@ -46,8 +46,6 @@ T> Unlike [`DefinePlugin`](/plugins/define-plugin), default values are applied t

T> Default values of `null` and `undefined` behave differently. Use `undefined` for variables that _must_ be provided during bundling, or `null` if they are optional.

W> If an environment variable is not found during bundling and no default value was provided, webpack will throw an error instead of a warning.

**Example:**

Let's investigate the result when running the previous `EnvironmentPlugin` configuration on a test file `entry.js`:
Expand Down