-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
perf(css): only run postcss when needed #19061
base: main
Are you sure you want to change the base?
perf(css): only run postcss when needed #19061
Conversation
// postcss processing is not needed | ||
if ( | ||
lang === 'css' && | ||
lang !== 'sss' && | ||
!postcssConfig && | ||
!isModule && | ||
!needInlineImport && | ||
!hasUrl | ||
) { | ||
return { code, map: null } | ||
return { code, map: preprocessorMap ?? null, deps } | ||
} |
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.
With this PR, If the preprocessor removed all @import
, we might be able to return at this line. (previously postcss was run)
if ( | ||
urlReplacer && | ||
// if there's an @import, we need to add this plugin | ||
// regradless of whether it contains url() or image-set(), | ||
// because we don't know the content referenced by @import | ||
(needInlineImport || cssUrlRE.test(code) || cssImageSetRE.test(code)) | ||
) { | ||
postcssPlugins.push( | ||
UrlRewritePostcssPlugin({ | ||
replacer: urlReplacer, |
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.
UrlRewritePostcssPlugin
was always pushed, so postcss was ran always.
@@ -1428,7 +1433,7 @@ async function compileCSS( | |||
) | |||
} | |||
|
|||
if (!postcssPlugins.length) { | |||
if (lang !== 'sss' && !postcssPlugins.length) { |
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.
This lang !== 'sss'
was not needed because !postcssPlugins.length
was always false
.
@@ -1509,7 +1516,6 @@ async function compileCSS( | |||
|
|||
if (!devSourcemap) { | |||
return { | |||
ast: postcssResult, |
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.
ast
was not used anywhere.
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.
The sourcemaps changed because postcss does not run on these files anymore.
/ecosystem-ci run |
commit: |
📝 Ran ecosystem CI on
✅ analogjs, astro, laravel, marko, nuxt, previewjs, quasar, qwik, rakkas, storybook, sveltekit, unocss, vike, vite-environment-examples, vite-plugin-pwa, vite-plugin-react, vite-plugin-react-swc, vite-plugin-vue, vite-setup-catalogue, vitepress, vuepress |
ladle fail is not related to this PR. vitest is failing because of the change in #19004. So it should be fine. |
Description