@@ -622,7 +622,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
622622 } else if ( inlined ) {
623623 let content = css
624624 if ( config . build . cssMinify ) {
625- content = await minifyCSS ( content , config , true )
625+ content = await minifyCSS ( content , config , true , id )
626626 }
627627 code = `export default ${ JSON . stringify ( content ) } `
628628 } else {
@@ -2202,6 +2202,7 @@ async function minifyCSS(
22022202 css : string ,
22032203 config : ResolvedConfig ,
22042204 inlined : boolean ,
2205+ filename : string = defaultCssBundleName ,
22052206) {
22062207 // We want inlined CSS to not end with a linebreak, while ensuring that
22072208 // regular CSS assets do end with a linebreak.
@@ -2213,6 +2214,7 @@ async function minifyCSS(
22132214 const { code, warnings } = await transform ( css , {
22142215 loader : 'css' ,
22152216 target : config . build . cssTarget || undefined ,
2217+ sourcefile : filename ,
22162218 ...resolveMinifyCssEsbuildOptions ( config . esbuild || { } ) ,
22172219 } )
22182220 if ( warnings . length ) {
@@ -2239,9 +2241,7 @@ async function minifyCSS(
22392241 ...config . css . lightningcss ,
22402242 targets : convertTargets ( config . build . cssTarget ) ,
22412243 cssModules : undefined ,
2242- // TODO: Pass actual filename here, which can also be passed to esbuild's
2243- // `sourcefile` option below to improve error messages
2244- filename : defaultCssBundleName ,
2244+ filename,
22452245 code : Buffer . from ( css ) ,
22462246 minify : true ,
22472247 } )
0 commit comments