Skip to content

Conversation

@chenjiahan
Copy link
Member

Summary

This update ensures that CSS transformations in SSR (Node) bundles use the same browserslist targets as web bundles.

Since inline CSS (e.g. .css?inline) is rendered in the browser, using a Node-specific target could cause inconsistent prefixing or feature transformations between server and client.

With this change, the LightningCSS transforming now respects the same browser targets across both web and SSR builds, ensuring consistent styles and hydration.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 12, 2025 02:52
@netlify
Copy link

netlify bot commented Nov 12, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 90448f1
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/6913fc3aa8a8190008d9b030
😎 Deploy Preview https://deploy-preview-6558--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 62 (🟢 up 5 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot finished reviewing on behalf of chenjiahan November 12, 2025 02:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures consistent CSS transformations between SSR (Node) and client (Web) bundles by using the same browserslist targets for LightningCSS processing. This prevents hydration mismatches caused by different CSS prefixing or feature transformations between server and client.

Key changes:

  • Modified the CSS plugin to detect when processing inline CSS in a Node environment and use the web environment's browserslist targets instead
  • Updated test configuration to use multi-environment setup with both web and node targets
  • Added browserslist configuration file to verify correct CSS transformation with vendor prefixes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/core/src/plugins/css.ts Added logic to use web environment's browserslist when processing CSS in node target to ensure consistent output
e2e/cases/css/inline-query-node-target/rsbuild.config.ts Updated test config to use multi-environment setup (web + node) instead of single node target
e2e/cases/css/inline-query-node-target/.browserslistrc Added browserslist config to specify browser targets for CSS transformation testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 372 to 381
// Use the same browserslist as web bundles to ensure consistent CSS output
// Prevent mismatched prefixes or features between SSR and client hydration
let { browserslist } = environment;
if (target === 'node') {
const webEnvironment = Object.values(environments).find(
(env) => env.config.output.target === 'web',
);
if (webEnvironment?.browserslist) {
browserslist = webEnvironment.browserslist;
}

Choose a reason for hiding this comment

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

P1 Badge Handle browserslist per matching web environment

When a build defines several web environments with different browserslists (e.g. modern and legacy clients) and corresponding SSR node bundles, this hook always copies the browserslist from the first environment whose output.target === 'web'. Any other node environment will therefore minify inline CSS with the wrong targets, reintroducing the very mismatch this change tries to avoid. The code should either map node environments to their intended client environment or only apply the override when there is exactly one web environment.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion, but we are not currently able to link the web environment with the corresponding Node environment, so this usage is not supported at the moment.

@chenjiahan chenjiahan merged commit 72fed9f into main Nov 12, 2025
11 checks passed
@chenjiahan chenjiahan deleted the ssr_css_transform_1112 branch November 12, 2025 03:30
@chenjiahan chenjiahan mentioned this pull request Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants