Skip to content

fix(css): show filename in CSS minification warnings for .css?inline - #22292

Merged
sapphi-red merged 1 commit into
vitejs:mainfrom
Jah-yee:fix/css-minify-filename
Apr 23, 2026
Merged

fix(css): show filename in CSS minification warnings for .css?inline#22292
sapphi-red merged 1 commit into
vitejs:mainfrom
Jah-yee:fix/css-minify-filename

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Good day

When CSS minification produces warnings, the filename was showing as <stdin> which made it difficult to track down which file had the issue.

This change passes the actual filename to esbuild's sourcefile option and to lightningcss, so that warning messages now contain the correct filename instead of <stdin>.

#15915

Changes

  • Add filename parameter to minifyCSS function with default value defaultCssBundleName
  • Pass filename to esbuild's sourcefile option for better warning messages
  • Pass actual filename to lightningcss instead of hardcoded defaultCssBundleName
  • For inlined CSS, use module ID as the filename

Before

warnings when minifying css:
▲ [WARNING] Unexpected "{" [css-syntax-error]

    <stdin>:484:1:
      484 │  {
          ╵  ^

After

The warning message will now show the actual filename instead of <stdin>.


Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
Jah-yee

…cation warnings

When CSS minification produces warnings, the filename was showing as
'<stdin>' which made it difficult to track down which file had the issue.

This change passes the actual filename to esbuild's 'sourcefile' option
and to lightningcss, so that warning messages now contain the correct
filename instead of '<stdin>'.

Fixes vitejs#15915

ghost commented Apr 22, 2026

Copy link
Copy Markdown
Member

I've removed the marked fix for #15915 for now as the issue has linked PRs that are different to this that we may still want to address.

@ghost ghost changed the title fix(css): pass filename to esbuild and lightningcss for better minification warnings fix(css): show filename in CSS minification warnings for .css?inline Apr 23, 2026
@ghost ghost added feat: css p2-edge-case Bug, but has workaround or limited in scope (priority) labels Apr 23, 2026
@ghost
ghost merged commit 83f0a78 into vitejs:main Apr 23, 2026
@ghost
ghost deleted the fix/css-minify-filename branch April 24, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: css p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants