Skip to content

Commit 29efde5

Browse files
EugeneHlushkomontogeek
authored andcommitted
docs(plugins): Move code example related warning to the code blocks (#2638)
Move related code example warning to the code block itself in order to avoid confusion, many come to see how to use `NODE_ENV` so the previous block location was too deep without giving appropriate warning immediately.
1 parent 9162178 commit 29efde5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/content/plugins/define-plugin.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ contributors:
88
- smonusbonus
99
---
1010

11-
The `DefinePlugin` allows you to create global constants which can be configured at __compile__ time. This can be useful for allowing different behavior between development builds and release builds. If you perform logging in your development build but not in the release build you might use a global constant to determine whether logging takes place. That's where `DefinePlugin` shines, set it and forget it rules for development and release builds.
11+
12+
The `DefinePlugin` allows you to create global constants which can be configured at __compile__ time. This can be useful for allowing different behavior between development builds and production builds. If you perform logging in your development build but not in the production build you might use a global constant to determine whether logging takes place. That's where `DefinePlugin` shines, set it and forget it rules for development and production builds.
1213

1314
``` javascript
1415
new webpack.DefinePlugin({
@@ -44,6 +45,9 @@ console.log('Running App version ' + VERSION);
4445
if(!BROWSER_SUPPORTS_HTML5) require('html5shiv');
4546
```
4647

48+
49+
W> When defining values for `process` prefer `'process.env.NODE_ENV': JSON.stringify('production')` over `process: { env: { NODE_ENV: JSON.stringify('production') } }`. Using the latter will overwrite the `process` object which can break compatibility with some modules that expect other values on the process object to be defined.
50+
4751
T> Note that because the plugin does a direct text replacement, the value given to it must include __actual quotes__ inside of the string itself. Typically, this is done either with alternate quotes, such as `'"production"'`, or by using `JSON.stringify('production')`.
4852

4953
__index.js__
@@ -87,8 +91,6 @@ new webpack.DefinePlugin({
8791
});
8892
```
8993

90-
W> When defining values for `process` prefer `'process.env.NODE_ENV': JSON.stringify('production')` over `process: { env: { NODE_ENV: JSON.stringify('production') } }`. Using the latter will overwrite the `process` object which can break compatibility with some modules that expect other values on the process object to be defined.
91-
9294

9395
## Service URLs
9496

0 commit comments

Comments
 (0)