fix(css): fix missing source file warning with sass modern api custom importer (#18113)

This commit is contained in:
Hiroshi Ogawa 2024-09-24 12:47:31 +09:00 committed by GitHub
parent 4cc53224e9
commit d7763a5615
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 6 deletions

View File

@ -2300,7 +2300,7 @@ const makeModernScssWorker = (
fileURLToPath(canonicalUrl),
options.filename,
)
return { contents, syntax }
return { contents, syntax, sourceMapUrl: canonicalUrl }
},
}
sassOptions.importers = [
@ -2395,7 +2395,7 @@ const makeModernCompilerScssWorker = (
)
const contents =
result.contents ?? (await fsp.readFile(result.file, 'utf-8'))
return { contents, syntax }
return { contents, syntax, sourceMapUrl: canonicalUrl }
},
}
sassOptions.importers = [

View File

@ -139,14 +139,19 @@ describe.runIf(isServe)('serve', () => {
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
{
"ignoreList": [],
"mappings": "AACE;EACE",
"mappings": "AAGE;EACE,UCJM",
"sources": [
"/root/imported.sass",
"/root/imported-nested.sass",
],
"sourcesContent": [
".imported
"@import "/imported-nested.sass"
.imported
&-sass
color: red
color: $primary
",
"$primary: red
",
],
"version": 3,

View File

@ -0,0 +1 @@
$primary: red

View File

@ -1,3 +1,5 @@
@import "/imported-nested.sass"
.imported
&-sass
color: red
color: $primary