From 73a97984cde8dde304917e2ce1fb8e05e2a24022 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 16 Mar 2023 20:04:55 +0100 Subject: [PATCH] fix(css): inject source content conditionally --- packages/vite/src/node/plugins/css.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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