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
Copy file name to clipboardExpand all lines: content/docs/optimizing-performance.md
+23-24Lines changed: 23 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,14 @@ Remember that only React files ending with `.production.min.js` are suitable for
51
51
52
52
### Brunch {#brunch}
53
53
54
-
For the most efficient Brunch production build, install the [`uglify-js-brunch`](https://github.com/brunch/uglify-js-brunch) plugin:
54
+
For the most efficient Brunch production build, install the [`terser-brunch`](https://github.com/brunch/terser-brunch) plugin:
55
55
56
56
```
57
57
# If you use npm
58
-
npm install --save-dev uglify-js-brunch
58
+
npm install --save-dev terser-brunch
59
59
60
60
# If you use Yarn
61
-
yarn add --dev uglify-js-brunch
61
+
yarn add --dev terser-brunch
62
62
```
63
63
64
64
Then, to create a production build, add the `-p` flag to the `build` command:
@@ -75,51 +75,46 @@ For the most efficient Browserify production build, install a few plugins:
75
75
76
76
```
77
77
# If you use npm
78
-
npm install --save-dev envify uglify-js uglifyify
78
+
npm install --save-dev envify terser uglifyify
79
79
80
80
# If you use Yarn
81
-
yarn add --dev envify uglify-js uglifyify
81
+
yarn add --dev envify terser uglifyify
82
82
```
83
83
84
84
To create a production build, make sure that you add these transforms **(the order matters)**:
85
85
86
86
* The [`envify`](https://github.com/hughsk/envify) transform ensures the right build environment is set. Make it global (`-g`).
87
87
* The [`uglifyify`](https://github.com/hughsk/uglifyify) transform removes development imports. Make it global too (`-g`).
88
-
* Finally, the resulting bundle is piped to [`uglify-js`](https://github.com/mishoo/UglifyJS2) for mangling ([read why](https://github.com/hughsk/uglifyify#motivationusage)).
88
+
* Finally, the resulting bundle is piped to [`terser`](https://github.com/terser-js/terser) for mangling ([read why](https://github.com/hughsk/uglifyify#motivationusage)).
89
89
90
90
For example:
91
91
92
92
```
93
93
browserify ./index.js \
94
94
-g [ envify --NODE_ENV production ] \
95
95
-g uglifyify \
96
-
| uglifyjs --compress --mangle > ./bundle.js
96
+
| terser --compress --mangle > ./bundle.js
97
97
```
98
98
99
-
>**Note:**
100
-
>
101
-
>The package name is `uglify-js`, but the binary it provides is called `uglifyjs`.<br>
102
-
>This is not a typo.
103
-
104
99
Remember that you only need to do this for production builds. You shouldn't apply these plugins in development because they will hide useful React warnings, and make the builds much slower.
105
100
106
101
### Rollup {#rollup}
107
102
108
103
For the most efficient Rollup production build, install a few plugins:
For a complete setup example [see this gist](https://gist.github.com/Rich-Harris/cb14f4bc0670c47d00d191565be36bf0).
137
132
138
-
Remember that you only need to do this for production builds. You shouldn't apply the `uglify` plugin or the `replace` plugin with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
133
+
Remember that you only need to do this for production builds. You shouldn't apply the `terser` plugin or the `replace` plugin with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
139
134
140
135
### webpack {#webpack}
141
136
@@ -144,18 +139,22 @@ Remember that you only need to do this for production builds. You shouldn't appl
minimizer: [newTerserPlugin({ /* additional options here */ })],
151
+
},
152
+
};
154
153
```
155
154
156
155
You can learn more about this in [webpack documentation](https://webpack.js.org/guides/production/).
157
156
158
-
Remember that you only need to do this for production builds. You shouldn't apply `UglifyJsPlugin` or `DefinePlugin` with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
157
+
Remember that you only need to do this for production builds. You shouldn't apply `TerserPlugin`in development because it will hide useful React warnings, and make the builds much slower.
159
158
160
159
## Profiling Components with the Chrome Performance Tab {#profiling-components-with-the-chrome-performance-tab}
0 commit comments