-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
perf(css): improve postcss config resolve #12484
Conversation
Run & review this pull request in StackBlitz Codeflow. |
const postcssConfig = await resolvePostcssConfig(config, getCssDialect(lang)) | ||
const postcssConfig = await resolvePostcssConfig(config) |
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.
Dialect option can be removed as it was only separated because sugarss mutates the config to add the sugarss parser. Down the code I've refactored to not mutate the config so we can keep a single cache as before.
This is awesome 🔥 |
Co-authored-by: patak <matias.capeletto@gmail.com>
Description
With many parallel CSS file requests (especially with
preTransformRequest
), each CSS will try to resolve thepostcss
config because the cache has not been filled. This is slow as we only need one CSS file to resolve it, while others can wait for that one result. Otherwise all CSS files will resolve their own postcss config at once, causing slowness.On top of that,
postcss-load-config
takes strangely long to load (2s for me), especially if you don't have a config at all. So we need to reduce calling it.This PR does the above by caching the promise of the config resolve, instead of it's result.
Additional context
Debugging the slowness in https://github.com/sveltejs/vite-plugin-svelte/tree/main/packages/playground/big
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).