Skip to content

feat: add styles.entries config for injecting global stylesheets#929

Merged
stevenle merged 2 commits intomainfrom
codex/add-user-config-field-for-styles
Feb 25, 2026
Merged

feat: add styles.entries config for injecting global stylesheets#929
stevenle merged 2 commits intomainfrom
codex/add-user-config-field-for-styles

Conversation

@stevenle
Copy link
Member

Motivation

  • Provide a way for projects to manually declare global stylesheet files to be injected as <link rel="stylesheet"> tags on every rendered page.
  • Ensure manually declared styles can be ordered before auto-collected CSS dependencies and are normalized relative to the site's base path.

Description

  • Added a new styles section to RootUserConfig with entries?: string[] and documentation on normalization and de-duplication.
  • Updated the Renderer to merge configured stylesheet entries into the cssDeps set before collecting auto-collected CSS, so manual entries appear first and duplicates are de-duped.
  • Implemented getConfiguredStyleEntries() to normalize configured entries against rootConfig.base and introduced normalizeStyleEntry(entry, basePath) to produce URL-safe paths.
  • Left existing CSS collection and element/script dependency handling intact while ensuring manual styles are included in the generated styleTags.

Testing

  • No automated tests were added or executed as part of this change.

Codex Task

@stevenle
Copy link
Member Author

@jeremydw here's the codex recommended pr for the #925. once this is in i think i'll need to update #928 (root-tailwind plugin) to use this config instead of it creating a vite plugin for auto tailwind css imports.

@jeremydw
Copy link
Member

Hm OK - I think it's alright, some feedback:

  1. Better name than entries? Not sure.
  2. What if the file should be imported in some routes but not all...? Is there a pattern we can follow for that or should we treat that as out of scope?

Of course I'm OK merging as is because I think getting the feature in is pretty important but just wanted to point these 2 things out

@stevenle
Copy link
Member Author

i think codex chose "entries" because it's consistent with vite naming, the only other thing i could think of is "entrypoints". "include" could work but it's a little more ambiguous for its purpose (e.g. someone may think to use "include" as a way of saying "these are all the css files that should be available in the site").

out of scope for limiting per route, we should continue to use import '<path>.css' for that. this should be intended as "global css" for configuration purposes (e.g. setting up design system tokens, css cascade layers, tailwind themes, etc.)

@jeremydw
Copy link
Member

lgtm

@stevenle stevenle changed the title Add styles.entries config and inject configured stylesheet links during render feat: add styles.entries config for injecting global stylesheets Feb 25, 2026
@stevenle stevenle merged commit 1fbaa7a into main Feb 25, 2026
1 check passed
@stevenle stevenle deleted the codex/add-user-config-field-for-styles branch February 25, 2026 05:20
@github-actions github-actions bot mentioned this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants