Vite "[vite:css]" - Fix CSS/PostCSS Build Errors in CI
The vite:css plugin failed while transforming a stylesheet. The cause is in the CSS pipeline - a PostCSS/Sass plugin throwing, a syntax error in the stylesheet, or an @import/url() that does not resolve.
What this error means
The build fails with a [vite:css] error naming the stylesheet and the underlying failure. It can be a parse error, a missing PostCSS plugin, or an unresolved import referenced from CSS.
[vite:css] Failed to load PostCSS config: Cannot find module 'autoprefixer'
file: /app/src/styles/main.css
at Object.<anonymous> (postcss.config.js:3:18)
error during build:Common causes
A PostCSS/Sass plugin throws or is missing
A plugin referenced in postcss.config.js (or a Sass feature) is not installed or errors on the input, so the CSS transform fails.
Syntax error in the stylesheet
A malformed rule, an unclosed brace, or an invalid at-rule makes the CSS parser throw during the transform.
Unresolved @import or url() asset
A CSS @import or url() points at a file that does not exist (wrong path or case), which the CSS plugin cannot resolve at build time.
How to fix it
Install the missing CSS tooling
Add every PostCSS plugin your config references as a dev dependency.
npm install -D autoprefixer postcss
npm ls autoprefixer # confirm it resolvesRead the underlying CSS error
- The
[vite:css]line wraps the real cause - read the message beneath it (parse error, missing module, unresolved import). - Fix the stylesheet syntax or correct the
@import/url()path and case. - Confirm
postcss.config.jsonly references installed plugins.
How to prevent it
- Declare every PostCSS/Sass plugin in
devDependencies. - Run
vite buildin CI so CSS-pipeline errors fail before deploy. - Match
@import/url()paths and casing to real files.