Skip to content

Commit

Permalink
docs(plugins): Move code example related warning to the code blocks (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
EugeneHlushko authored and montogeek committed Nov 12, 2018
1 parent 9162178 commit 29efde5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/content/plugins/define-plugin.md
Expand Up @@ -8,7 +8,8 @@ contributors:
- smonusbonus
---

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.

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.

``` javascript
new webpack.DefinePlugin({
Expand Down Expand Up @@ -44,6 +45,9 @@ console.log('Running App version ' + VERSION);
if(!BROWSER_SUPPORTS_HTML5) require('html5shiv');
```


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.

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')`.

__index.js__
Expand Down Expand Up @@ -87,8 +91,6 @@ new webpack.DefinePlugin({
});
```

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.


## Service URLs

Expand Down

0 comments on commit 29efde5

Please sign in to comment.