Back to all fixes
CuratedTypeScriptVite 8local
"vite tried to access esbuild (a peer dependency) but it isn't provided" in [plugin vite:css-post]
Problem
Production build fails under Yarn Berry/PnP (or any package manager enforcing strict peer-dependency resolution) with: `[plugin vite:css-post] Error: vite tried to access esbuild (a peer dependency) but it isn't provided by its ancestors`. Happens because in Vite 8, `esbuild` became an optional peer dependency (Rolldown replaced it, and `build.cssMinify` now defaults to `lightningcss`), but a plugin in the chain (e.g. Vike) explicitly overrides `build.cssMinify` back to `'esbuild'` without esbuild being an installed dependency.
Solution
typescript
Two confirmed angles: (1) the practical fix is on the plugin/app side - do not let a framework plugin force `build.cssMinify: 'esbuild'`; either install `esbuild` explicitly as a direct dependency so PnP's strict resolution can see it, or override the plugin's forced setting back with `build.cssMinify: 'lightningcss'` in your own vite.config.ts (applied after the plugin). (2) On the Vite side, PR #22632 proposed wrapping the internal dynamic `import('esbuild')` in a try/catch so PnP's resolution error doesn't crash the build outright, but this PR was not merged, so don't rely on a Vite-side fix landing automatically - use workaround (1).