Skip to content

Commit 7d47fc1

Browse files
sapphi-redhi-ogawa
andauthored
fix(css): backport #18113, fix missing source file warning with sass modern api custom importer (#18183)
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
1 parent 93b6205 commit 7d47fc1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

packages/vite/src/node/plugins/css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ const makeModernScssWorker = (
22672267
fileURLToPath(canonicalUrl),
22682268
options.filename,
22692269
)
2270-
return { contents, syntax }
2270+
return { contents, syntax, sourceMapUrl: canonicalUrl }
22712271
},
22722272
}
22732273
sassOptions.importers = [
@@ -2353,7 +2353,7 @@ const makeModernCompilerScssWorker = (
23532353
)
23542354
const contents =
23552355
result.contents ?? (await fsp.readFile(result.file, 'utf-8'))
2356-
return { contents, syntax }
2356+
return { contents, syntax, sourceMapUrl: canonicalUrl }
23572357
},
23582358
}
23592359
sassOptions.importers = [

playground/css-sourcemap/__tests__/css-sourcemap.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,19 @@ describe.runIf(isServe)('serve', () => {
139139
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
140140
{
141141
"ignoreList": [],
142-
"mappings": "AACE;EACE",
142+
"mappings": "AAGE;EACE,UCJM",
143143
"sources": [
144144
"/root/imported.sass",
145+
"/root/imported-nested.sass",
145146
],
146147
"sourcesContent": [
147-
".imported
148+
"@import "/imported-nested.sass"
149+
150+
.imported
148151
&-sass
149-
color: red
152+
color: $primary
153+
",
154+
"$primary: red
150155
",
151156
],
152157
"version": 3,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$primary: red
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "/imported-nested.sass"
2+
13
.imported
24
&-sass
3-
color: red
5+
color: $primary

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy