Skip to content

Fix CSS not being inlined in dashboard HTML#51

Open
stevelandeydescript wants to merge 2 commits intomainfrom
fix-css-inlining
Open

Fix CSS not being inlined in dashboard HTML#51
stevelandeydescript wants to merge 2 commits intomainfrom
fix-css-inlining

Conversation

@stevelandeydescript
Copy link
Copy Markdown
Collaborator

@stevelandeydescript stevelandeydescript commented May 1, 2026

tsdown/rolldown's native CSS handling was intercepting .css imports before our inlineRawFiles plugin could run, extracting them into separate files and exporting empty objects. The dashboard's styles.css was silently dropped from the HTML output, leaving all tabs, provider pills, and badge styling unstyled.

Fixed by adding a resolveId hook that redirects .css imports to a virtual .cssraw extension, bypassing rolldown's CSS extraction while still reading and inlining the file content via the load hook.


Note

Low Risk
Low risk build-config change limited to how .css files are resolved/loaded for bundling; main risk is unexpected handling of CSS import resolution paths.

Overview
Fixes CSS imports being dropped/extracted during bundling by updating inlineRawFiles in tsdown.config.ts.

The plugin now intercepts .css imports in resolveId and rewrites them to a virtual .cssraw path, then load reads the original file and exports its contents as a string so CSS is inlined instead of handled by rolldown’s native CSS pipeline.

Reviewed by Cursor Bugbot for commit 2f17886. Bugbot is set up for automated code reviews on this repo. Configure here.

tsdown/rolldown's native CSS handling was intercepting .css imports
before our inlineRawFiles plugin could run, extracting them into
separate files and exporting empty objects. The dashboard's styles.css
was silently dropped from the HTML output, leaving all tabs, provider
pills, and badge styling unstyled.

Fixed by adding a resolveId hook that redirects .css imports to a
virtual .cssraw extension, bypassing rolldown's CSS extraction while
still reading and inlining the file content via the load hook.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Windows paths lose drive letter in URL resolution
    • Replaced manual file:// URL construction with path.resolve(dirname(importer), source), which correctly handles Windows drive letters and avoids URL encoding issues.

Create PR

Or push these changes by commenting:

@cursor push e733d422cd
Preview (e733d422cd)
diff --git a/tsdown.config.ts b/tsdown.config.ts
--- a/tsdown.config.ts
+++ b/tsdown.config.ts
@@ -1,4 +1,5 @@
 import { readFileSync } from 'node:fs';
+import { dirname, resolve } from 'node:path';
 import { defineConfig } from 'tsdown';
 import type { Plugin } from 'rolldown';
 
@@ -9,7 +10,7 @@
             // Redirect .css imports to a virtual .cssraw ID so rolldown's
             // native CSS handling doesn't extract them into separate files.
             if (source.endsWith('.css') && importer) {
-                const resolved = new URL(source, 'file://' + importer).pathname;
+                const resolved = resolve(dirname(importer), source);
                 return { id: resolved + '.cssraw' };
             }
         },

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 2f6bdec. Configure here.

Comment thread tsdown.config.ts Outdated
new URL(source, 'file://' + importer) produces a malformed URL on
Windows where the drive letter becomes the hostname. Use
path.resolve(dirname(importer), source) which handles all platforms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants