Skip to content

Commit

Permalink
fix: fix sass modern source map
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Aug 24, 2024
1 parent 488a204 commit e6450ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e6450ac

Please sign in to comment.