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: src/content/guides/production.md
+32-43
Original file line number
Diff line number
Diff line change
@@ -148,42 +148,6 @@ __package.json__
148
148
Feel free to run those scripts and see how the output changes as we continue adding to our _production_ configuration.
149
149
150
150
151
-
## Minification
152
-
153
-
Note that while the [`UglifyJSPlugin`](/plugins/uglifyjs-webpack-plugin) is a great place to start for minification, there are other options out there. Here are a few more popular ones:
If you decide to try another minification plugin, just make sure your new choice also drops dead code as described in the [tree shaking](/guides/tree-shaking) guide.
159
-
160
-
161
-
## Source Mapping
162
-
163
-
We encourage you to have source maps enabled in production, as they are useful for debugging as well as running benchmark tests. That said, you should choose one with a fairly quick build speed that's recommended for production use (see [`devtool`](/configuration/devtool)). For this guide, we'll use the `source-map` option in _production_ as opposed to the `inline-source-map` we used in _development_:
T> Avoid `inline-***` and `eval-***` use in production as they can increase bundle size and reduce the overall performance.
185
-
186
-
187
151
## Specify the Mode
188
152
189
153
Many libraries will key off the `process.env.NODE_ENV` variable to determine what should be included in the library. For example, when not in _production_ some libraries may add additional logging and testing to make debugging easier. However, with `process.env.NODE_ENV === 'production'` they might drop or add significant portions of code to optimize how things run for your actual users. Since webpack v4, specifying [`mode`](/concepts/mode/) automatically configures [`DefinePlugin`](/plugins/define-plugin) for you:
webpack v4+ will minify your code by default in [`production mode`](/concepts/mode/#mode-production).
198
+
199
+
Note that while the [`UglifyJSPlugin`](/plugins/uglifyjs-webpack-plugin) is a great place to start for minification and being used by default, there are other options out there. Here are a few more popular ones:
If you decide to try another minification plugin, just make sure your new choice also drops dead code as described in the [tree shaking](/guides/tree-shaking) guide and provide it as the [`optimization.minimizer`](/configuration/optimization/#optimization-minimizer).
205
+
206
+
207
+
## Source Mapping
208
+
209
+
We encourage you to have source maps enabled in production, as they are useful for debugging as well as running benchmark tests. That said, you should choose one with a fairly quick build speed that's recommended for production use (see [`devtool`](/configuration/devtool)). For this guide, we'll use the `source-map` option in _production_ as opposed to the `inline-source-map` we used in _development_:
210
+
211
+
__webpack.prod.js__
212
+
213
+
```diff
214
+
const merge = require('webpack-merge');
215
+
const common = require('./webpack.common.js');
216
+
217
+
module.exports = merge(common, {
218
+
mode: 'production',
219
+
+ devtool: 'source-map'
220
+
});
221
+
```
222
+
223
+
T> Avoid `inline-***` and `eval-***` use in production as they can increase bundle size and reduce the overall performance.
224
+
225
+
237
226
## Minimize CSS
238
227
239
228
It is crucial to minimize your CSS on production, please see [Minimizing for Production](/plugins/mini-css-extract-plugin/#minimizing-for-production) section.
0 commit comments