From 1565a02eb83d7f4d370967e4dc9c519b0cc5cd03 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Sat, 24 Aug 2024 11:24:00 +0900 Subject: [PATCH] fix: fix sass modern source map --- packages/vite/src/node/plugins/css.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index e447a486fc39b7..b65b356db7f4b2 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -2276,6 +2276,11 @@ const makeModernScssWorker = ( ] const result = await sass.compileStringAsync(data, sassOptions) + if (result.sourceMap) { + result.sourceMap.sources = result.sourceMap.sources.map((url) => + url.startsWith('file://') ? fileURLToPath(url) : url, + ) + } return { css: result.css, map: result.sourceMap ? JSON.stringify(result.sourceMap) : undefined, @@ -2362,6 +2367,11 @@ const makeModernCompilerScssWorker = ( ] const result = await compiler.compileStringAsync(data, sassOptions) + if (result.sourceMap) { + result.sourceMap.sources = result.sourceMap.sources.map((url) => + url.startsWith('file://') ? fileURLToPath(url) : url, + ) + } return { css: result.css, map: result.sourceMap ? JSON.stringify(result.sourceMap) : undefined,