diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 4956a90ca5fff9..ced7ddb77117f4 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -377,7 +377,9 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const getContentWithSourcemap = async (content: string) => { if (config.css?.devSourcemap) { const sourcemap = this.getCombinedSourcemap() - await injectSourcesContent(sourcemap, cleanUrl(id), config.logger) + if (sourcemap.mappings && !sourcemap.sourcesContent) { + await injectSourcesContent(sourcemap, cleanUrl(id), config.logger) + } return getCodeWithSourcemap('css', content, sourcemap) } return content