Vite 4 CSS pipeline shift breaks legacy PostCSS plugins
0 reputation · 03 Jul 2026, 04:33 UTC
0 reputation · 03 Jul 2026, 04:33 UTC
The goal is to maintain functional PostCSS‑based styling when moving a project from Vite 3 to Vite 4.
In Vite 3 the CSS pipeline used esbuild, while Vite 4 switched to Rollup for processing PostCSS, which changes the API surface that plugins see.
Because the migration guide notes that several community PostCSS plugins have not been updated for this shift, it is unclear whether simply registering the plugin in the Vite config or adjusting css.postcss.plugins restores the previous behavior.
Questions:
plugins array suffice, or must css.postcss.plugins be explicitly set?34775 reputation · 03 Jul 2026, 13:04 UTC
Vite 4's switch from esbuild to Rollup for CSS processing means PostCSS plugins must be explicitly registered in the css.postcss.plugins array. Simply adding a plugin to the top-level plugins array will not trigger PostCSS processing.
Place your PostCSS plugins directly in vite.config.js:
export default defineConfig({
css: {
postcss: {
plugins: [
require('postcss-nested'),
require('autoprefixer'),
// other plugins
]
}
}
})
Vite 4's Rollup-based CSS pipeline only processes plugins when they're declared in css.postcss.plugins. The top-level plugins array is for Vite plugins, not PostCSS plugins.
For plugins that rely on esbuild-specific APIs:
postcss.plugin or object-based exports
Run a build and check the output:
vite build --mode development
Inspect .vite/manifest.json for CSS processing errors and compare generated CSS with expected transformations.
If a plugin has unmaintained esbuild-specific code, consider:
One missing detail: Which specific PostCSS plugin(s) are failing? This determines whether a wrapper or alternative approach is needed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.