Skip to content

Commit

Permalink
fix(css): fix missing source file warning with sass modern api custom…
Browse files Browse the repository at this point in the history
… importer (#18113)
  • Loading branch information
hi-ogawa authored Sep 24, 2024
1 parent 4cc5322 commit d7763a5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ const makeModernScssWorker = (
fileURLToPath(canonicalUrl),
options.filename,
)
return { contents, syntax }
return { contents, syntax, sourceMapUrl: canonicalUrl }
},
}
sassOptions.importers = [
Expand Down Expand Up @@ -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 = [
Expand Down
11 changes: 8 additions & 3 deletions playground/css-sourcemap/__tests__/css-sourcemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions playground/css-sourcemap/imported-nested.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$primary: red
4 changes: 3 additions & 1 deletion playground/css-sourcemap/imported.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "/imported-nested.sass"

.imported
&-sass
color: red
color: $primary

0 comments on commit d7763a5

Please sign in to comment.