Skip to content

Commit

Permalink
docs(configuration): sort performance options (webpack#5295)
Browse files Browse the repository at this point in the history
* docs: move performance.assetFilters

* docs(configuration): move performance.maxAssetSize

* docs(configuration): fix heading levels for performance
  • Loading branch information
snitin315 authored Aug 15, 2021
1 parent a7d26c6 commit 8501d04
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions src/content/configuration/performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,34 @@ This feature was inspired by the idea of [webpack Performance Budgets](https://g

Configure how performance hints are shown. For example if you have an asset that is over 250kb, webpack will emit a warning notifying you of this.

## `performance.hints`
### performance.assetFilter

`function(assetFilename) => boolean`

This property allows webpack to control what files are used to calculate performance hints. The default function is:

```js
function assetFilter(assetFilename) {
return !/\.map$/.test(assetFilename);
}
```

You can override this property by passing your own function in:

```js
module.exports = {
//...
performance: {
assetFilter: function (assetFilename) {
return assetFilename.endsWith('.js');
},
},
};
```

The example above will only give you performance hints based on `.js` files.

### performance.hints

`string = 'warning': 'error' | 'warning'` `boolean: false`

Expand Down Expand Up @@ -59,22 +86,7 @@ module.exports = {

An error will be displayed notifying you of a large asset. We recommend using `hints: "error"` during production builds to help prevent deploying production bundles that are too large, impacting webpage performance.

## `performance.maxEntrypointSize`

`number = 250000`

An entry point represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entry point size in bytes.

```js
module.exports = {
//...
performance: {
maxEntrypointSize: 400000,
},
};
```

## `performance.maxAssetSize`
### performance.maxAssetSize

`number = 250000`

Expand All @@ -89,29 +101,17 @@ module.exports = {
};
```

## `performance.assetFilter`

`function(assetFilename) => boolean`

This property allows webpack to control what files are used to calculate performance hints. The default function is:
### performance.maxEntrypointSize

```js
function assetFilter(assetFilename) {
return !/\.map$/.test(assetFilename);
}
```
`number = 250000`

You can override this property by passing your own function in:
An entry point represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entry point size in bytes.

```js
module.exports = {
//...
performance: {
assetFilter: function (assetFilename) {
return assetFilename.endsWith('.js');
},
maxEntrypointSize: 400000,
},
};
```

The example above will only give you performance hints based on `.js` files.

0 comments on commit 8501d04

Please sign in to comment.