Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking netlify preview #2955

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/content/configuration/optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ title: Optimization
sort: 8
contributors:
- EugeneHlushko
- jeremenichelli
related:
- title: 'webpack 4: Code Splitting, chunk graph and the splitChunks optimization'
url: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
---

Optimization configuration allows you to control the webpack output optimization level.
Since version 4 webpack runs optimizations for you depending on the chosen `mode`, still all optimizations are available for manual configuration and overrides.


## `optimization.minimize`

`boolean`

Tell webpack to minimize the JavaScript output using the [UglifyjsWebpackPlugin](/plugins/uglifyjs-webpack-plugin/)
It is set to `true` by default in `production` [mode](/concepts/mode/).
Tell webpack to minimize the bundle using the [UglifyjsWebpackPlugin](/plugins/uglifyjs-webpack-plugin/).

This is `true` by default in `production` mode.

__webpack.config.js__

Expand All @@ -22,16 +27,18 @@ __webpack.config.js__
module.exports = {
//...
optimization: {
minimize: true
minimize: false
}
}
```

T> Learn how [mode](/concepts/mode/) works.

## `optimization.minimizer`

`UglifyjsWebpackPlugin | [UglifyjsWebpackPlugin]`

Allows to override default minimizer by providing one or more custom configured [UglifyjsWebpackPlugin](/plugins/uglifyjs-webpack-plugin/) instance(s).
Allows you to override the default minimizer by providing a different one or more customized [UglifyjsWebpackPlugin](/plugins/uglifyjs-webpack-plugin/) instances.

__webpack.config.js__

Expand All @@ -41,7 +48,7 @@ module.exports = {
//...
optimization: {
minimizer: [
new UglifyJsPlugin({ /* */ })
new webpack.optimize.UglifyJsPlugin({ /* your config */ })
]
}
}
Expand All @@ -51,4 +58,4 @@ module.exports = {

`object`

Tells webpack how to deal with code splitting. See configuration and available options on the [SplitChunksPlugin](/plugins/split-chunks-plugin/) page.
By default webpack v4+ provides new common chunks strategies out of the box for dynamically imported modules. See available options for configuring this behavior in the [SplitChunksPlugin](/plugins/split-chunks-plugin/) page.