@@ -42,6 +42,7 @@ import {
4242 normalizePath ,
4343 parseRequest ,
4444 processSrcSet ,
45+ removeDirectQuery ,
4546 requireResolveFromRootWithFallback
4647} from '../utils'
4748import type { Logger } from '../logger'
@@ -753,7 +754,6 @@ async function compileCSS(
753754 preprocessorOptions,
754755 devSourcemap
755756 } = config . css || { }
756- const fileName = cleanUrl ( id )
757757 const isModule = modulesOptions !== false && cssModuleRE . test ( id )
758758 // although at serve time it can work without processing, we do need to
759759 // crawl them in order to register watch dependencies.
@@ -801,7 +801,7 @@ async function compileCSS(
801801 }
802802 }
803803 // important: set this for relative import resolving
804- opts . filename = fileName
804+ opts . filename = cleanUrl ( id )
805805 opts . enableSourcemap = devSourcemap ?? false
806806
807807 const preprocessResult = await preProcessor (
@@ -915,13 +915,14 @@ async function compileCSS(
915915
916916 let postcssResult : PostCSS . Result
917917 try {
918+ const source = removeDirectQuery ( id )
918919 // postcss is an unbundled dep and should be lazy imported
919920 postcssResult = await ( await import ( 'postcss' ) )
920921 . default ( postcssPlugins )
921922 . process ( code , {
922923 ...postcssOptions ,
923- to : fileName ,
924- from : fileName ,
924+ to : source ,
925+ from : source ,
925926 ...( devSourcemap
926927 ? {
927928 map : {
@@ -991,13 +992,13 @@ async function compileCSS(
991992 // version property of rawPostcssMap is declared as string
992993 // but actually it is a number
993994 rawPostcssMap as Omit < RawSourceMap , 'version' > as ExistingRawSourceMap ,
994- fileName
995+ cleanUrl ( id )
995996 )
996997
997998 return {
998999 ast : postcssResult ,
9991000 code : postcssResult . css ,
1000- map : combineSourcemapsIfExists ( fileName , postcssMap , preprocessorMap ) ,
1001+ map : combineSourcemapsIfExists ( cleanUrl ( id ) , postcssMap , preprocessorMap ) ,
10011002 modules,
10021003 deps
10031004 }
0 commit comments