Skip to content

Commit 885bc04

Browse files
committed
define-plugin: styling tweaks
1 parent 2e39e0b commit 885bc04

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

content/plugins/define-plugin.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ title: DefinePlugin
66
new webpack.DefinePlugin(definitions)
77
```
88

9-
The `DefinePlugin` allows you to create global constants which can be configured at **compile** time. This can be very useful for allowing different behaviour between development builds and release builds. For example, you might use a global constant to determine whether logging takes place; perhaps you perform logging in your development build but not in the release build. That's the sort of scenario the `DefinePlugin` facilitates.
9+
The `DefinePlugin` allows you to create global constants which can be configured at **compile** time. This can be very useful for allowing different behaviour between development builds and release builds. For example, you might use a global constant to determine whether logging takes place; perhaps you perform logging in your development build but not in the release build. That's the sort of scenario the `DefinePlugin` facilitates.
1010

11-
Example:
11+
**Example:**
1212

1313
``` javascript
1414
new webpack.DefinePlugin({
15-
PRODUCTION: JSON.stringify(true),
16-
VERSION: JSON.stringify("5fa3b9"),
17-
BROWSER_SUPPORTS_HTML5: true,
18-
TWO: "1+1",
19-
"typeof window": JSON.stringify("object")
15+
PRODUCTION: JSON.stringify(true),
16+
VERSION: JSON.stringify("5fa3b9"),
17+
BROWSER_SUPPORTS_HTML5: true,
18+
TWO: "1+1",
19+
"typeof window": JSON.stringify("object")
2020
})
2121
```
2222

@@ -36,21 +36,25 @@ Each key passed into `DefinePlugin` is an identifier or multiple identifiers joi
3636

3737
The values will be inlined into the code which allows a minification pass to remove the redundant conditional.
3838

39-
Example:
39+
**Example:**
4040

4141
``` javascript
42-
if (!PRODUCTION)
43-
console.log('Debug info')
44-
if (PRODUCTION)
45-
console.log('Production log')
42+
if (!PRODUCTION) {
43+
console.log('Debug info')
44+
}
45+
if (PRODUCTION) {
46+
console.log('Production log')
47+
}
4648
`````
4749
After passing through webpack with no minification results in:
4850

4951
``` javascript
50-
if (!true)
51-
console.log('Debug info')
52-
if (true)
53-
console.log('Production log')
52+
if (!true) {
53+
console.log('Debug info')
54+
}
55+
if (true) {
56+
console.log('Production log')
57+
}
5458
```
5559

5660
and then after a minification pass results in:

0 commit comments

Comments
 (0)