From a2530f6062ea9846f21e8ff4d5687fbf3628c1ac Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 3 Nov 2024 19:59:07 +0530 Subject: [PATCH] docs(plugins): update EnvironmentPlugin warning --- src/content/plugins/environment-plugin.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/content/plugins/environment-plugin.mdx b/src/content/plugins/environment-plugin.mdx index 68565f745ebf..e739c32b1c7f 100644 --- a/src/content/plugins/environment-plugin.mdx +++ b/src/content/plugins/environment-plugin.mdx @@ -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 @@ -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`: