-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
docs(performance): Add performance config documentation #500
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: Performance | ||
sort: 14 | ||
contributors: | ||
- thelarkinn | ||
--- | ||
|
||
These options allows you to control how webpack notifies you of assets and entrypoints that exceed a specific file limit. | ||
This feature was inspired by the idea of [webpack Performance Budgets](https://github.com/webpack/webpack/issues/3216). | ||
|
||
## `performance` | ||
|
||
`object` | ||
|
||
Configure how performance hints are shown. For example if you have an asset that is over 250kb, webpack will emit a warning notifiying you of this. | ||
|
||
|
||
## `performance.hints` | ||
|
||
`boolean | "error" | "warning"` | ||
|
||
Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are found. This property is set to `"warning"` by default. | ||
|
||
Given an asset is created that is over 250kb: | ||
|
||
```js | ||
performance: { | ||
hints: false | ||
} | ||
``` | ||
|
||
No hint warnings or errors are shown. | ||
|
||
```js | ||
performance: { | ||
hints: "warning" | ||
} | ||
``` | ||
|
||
A warning will be displayed notifying you of a large asset. We recommend something like this for development environments. | ||
|
||
```js | ||
performance: { | ||
hints: "error" | ||
} | ||
``` | ||
|
||
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` | ||
|
||
`int` | ||
|
||
An entrypoint 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 entrypoint size. The default value is `250000` (bytes). | ||
|
||
```js | ||
performance: { | ||
maxEntrypointSize: 400000 | ||
} | ||
``` | ||
|
||
## `performance.maxAssetSize` | ||
|
||
`int` | ||
|
||
An asset is any emitted file from webpack. This option controls when webpack emits a performance hint based on individual asset size. The default value is `250000` (bytes). | ||
|
||
|
||
```js | ||
performance: { | ||
maxAssetSize: 100000 | ||
} | ||
``` | ||
|
||
## `performance.assetFilter` | ||
|
||
`Function` | ||
|
||
This property allows webpack to control what files are used to calculate performance hints. The default function is seen below: | ||
|
||
```js | ||
function(assetFilename) { | ||
return !(/\.map$/.test(assetFilename)) | ||
}; | ||
``` | ||
|
||
You can override this property by passing your own function in: | ||
|
||
```js | ||
performance: { | ||
assetFilter: function(assetFilename) { | ||
return assetFilename.endsWith('.js'); | ||
} | ||
} | ||
``` | ||
|
||
The example above will only give you performance hints based on `.js` files. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say you are inlining assets during development, missing minification etc., wouldn't this yield warnings even if they aren't relevant? Isn't the best value in production build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but also gives perspective to users as they are developing.
If a bundle grows from 200->350kb after a certain feature, I'd want to know specifically about it while developing so I can trace my steps back a few changes and investigate more into what is causing the bloat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. I guess it takes more experience with the feature for me to tell any better. Hitting the limits is very easy by inlining just a few images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Developing the last thing I'd like is to be caught of guard after x hours of development to see errors because of size stuff I could maybe have caught in the act.
Again these are just hypothetical/estimates etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes true. Maybe that's where they could filter assets, etc.
I mean at the most these are recommendations but I 100% agree where you are coming from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have something like
--json
kind of flag for the perf data? Can you get it in JSON to track?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aww that would actually be a really cool feature but the log might be built. I'm going to add that to the original issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be big*