You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You usually do not write this `DefinePlugin` by hand. [`EnvironmentPlugin`](/plugins/webpack/environment-plugin), `NODE_ENV`, and user `DefinePlugin``import.meta.env.*` keys are collected into one accumulated env object and exposed as `import.meta.env` automatically. User `DefinePlugin``process.env.*` keys keep their `process.env` behavior and are not collected into `import.meta.env`.
193
+
When `experiments.env` is enabled, you usually do not write this `DefinePlugin` by hand. [`EnvironmentPlugin`](/plugins/webpack/environment-plugin), `NODE_ENV`, and user `DefinePlugin``import.meta.env.*` keys are collected into one accumulated env object and exposed as `import.meta.env` automatically. User `DefinePlugin``process.env.*` keys keep their `process.env` behavior and are not collected into `import.meta.env`.
191
194
192
195
## `process.env`
193
196
@@ -208,11 +211,11 @@ When the env object is accumulated (via [`EnvironmentPlugin`](/plugins/webpack/e
208
211
209
212
### Destructuring
210
213
211
-
`process.env` destructuring is supported: when every destructured key is a defined env key, the destructuring source is inlined with only those keys.
214
+
`process.env` destructuring is supported for corresponding `process.env.KEY` defines. When every destructured key has a matching `process.env.KEY` define, the destructuring source is inlined with only those keys.
212
215
213
216
```js title="src/index.js"
214
217
const { NODE_ENV, MODE } =process.env;
215
218
console.log(NODE_ENV, MODE);
216
219
```
217
220
218
-
If any destructured key is not a defined env key, the access falls back to the runtime `process.env`, since it may legitimately hold that key at runtime.
221
+
If any destructured key does not have a matching `process.env.KEY` define, the access falls back to the runtime `process.env`, since it may legitimately hold that key at runtime.
0 commit comments