Skip to content

Fix missing CSS when mixing SSR and prerendered routes#15322

Merged
matthewp merged 2 commits intonextfrom
fix-css-env-filtering
Jan 28, 2026
Merged

Fix missing CSS when mixing SSR and prerendered routes#15322
matthewp merged 2 commits intonextfrom
fix-css-env-filtering

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

@matthewp matthewp commented Jan 27, 2026

Summary

  • Fixes missing CSS when a project has both SSR and prerendered routes
  • Instead of returning empty code for duplicate CSS modules (which changed content hashes and broke filename matching), we now filter CSS-to-page assignments by environment type:
    • SSR build: only adds CSS to non-prerendered pages
    • Prerender build: only adds CSS to prerendered pages
    • Client build: adds CSS to all pages (unchanged)

Testing

  • Existing ssr-prerender test suite passes
  • Tested against astro.build which was experiencing missing CSS

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 14b32c2

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: react Related to React (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: integration Related to any renderer integration (scope) pkg: create-astro Related to the `create-astro` package (scope) pkg: astro Related to the core `astro` package (scope) docs pr labels Jan 27, 2026
@matthewp matthewp changed the base branch from main to next January 27, 2026 21:40
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label Jan 27, 2026
@github-actions github-actions bot removed the pr preview Apply this label to a PR to generate a preview release label Jan 27, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 27, 2026

npm i https://pkg.pr.new/astro@15322

commit: cd888a2

@alexanderniebuhr
Copy link
Copy Markdown
Member

@matthewp seems to work astrolicious/dotdev@423376a

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Awesome. Any is there any chance to add a test? It would be great to avoid possible regressions. Since existing tests were already passing, it probably means that we aren't testing against this particular use case.

@ashhitch
Copy link
Copy Markdown

@matthewp I have tested the PR on our project. on build, it resolves the styling issues.
However, in dev if a React component does not have a client: directive, then the styles do not render.

@alexanderniebuhr
Copy link
Copy Markdown
Member

As for a test for regressions, I think we need two pages one pre-rendered the other on demand which use the same style. Am
I right @matthewp?
Do you have a minimal repro already which we can use as a test?

@matthewp
Copy link
Copy Markdown
Contributor Author

You need more than just having the same styles, you need them to go into separate bundles. I'll see if I can add a test though.

@github-actions github-actions bot removed feat: markdown Related to Markdown (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions labels Jan 28, 2026
@github-actions github-actions bot removed pkg: react Related to React (scope) pkg: preact Related to Preact (scope) pkg: solid Related to Solid (scope) pkg: integration Related to any renderer integration (scope) pkg: create-astro Related to the `create-astro` package (scope) docs pr labels Jan 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Package Trust Level Decreased

Caution

Decreased trust levels may indicate a higher risk of supply chain attacks. Please review these changes carefully.

📦 Package 🔒 Before 🔓 After
eslint-plugin-regexp trusted-with-provenance none
@cloudflare/kv-asset-handler trusted-with-provenance none
@cloudflare/unenv-preset trusted-with-provenance none
workerd trusted-with-provenance none
@sveltejs/vite-plugin-svelte-inspector trusted-with-provenance provenance
@sveltejs/vite-plugin-svelte trusted-with-provenance provenance
jsdoc-type-pratt-parser trusted-with-provenance none
miniflare trusted-with-provenance none
youch provenance none
@cloudflare/workerd-darwin-64 trusted-with-provenance none
@cloudflare/workerd-darwin-arm64 trusted-with-provenance none
@cloudflare/workerd-linux-64 trusted-with-provenance none
@cloudflare/workerd-linux-arm64 trusted-with-provenance none
@cloudflare/workerd-windows-64 trusted-with-provenance none
wrangler trusted-with-provenance none

@matthewp matthewp merged commit 18e0980 into next Jan 28, 2026
22 of 23 checks passed
@matthewp matthewp deleted the fix-css-env-filtering branch January 28, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with ?raw imports when mixing SSR and prerendered routes

4 participants