Skip to content

Commit 1653cd0

Browse files
authored
chore(deps): use the native Rspack adapter for StyleX (#531)
1 parent e120e08 commit 1653cd0

4 files changed

Lines changed: 43 additions & 40 deletions

File tree

‎pnpm-lock.yaml‎

Lines changed: 40 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rsbuild/stylex/README.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ During development, `runtimeInjection` injects StyleX styles at runtime so style
66

77
In production, runtime injection is disabled. The plugin compiles StyleX at build time and appends the generated CSS to the stylesheet emitted by Rsbuild's `CssExtractRspackPlugin` (fed by `src/index.css`), producing content-hashed CSS filenames instead of a separate hardcoded `/stylex.css` link.
88

9-
This example uses `stylex.webpack()` (not `stylex.rspack()`) because `@stylexjs/unplugin` currently attaches CSS injection through the webpack-compatible hook; Rspack still runs that hook for plugins registered via `tools.rspack.plugins`.
10-
119
## Setup
1210

1311
Install the dependencies:

‎rsbuild/stylex/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"devDependencies": {
1717
"@rsbuild/core": "2.2.12",
1818
"@rsbuild/plugin-react": "^2.1.1",
19-
"@stylexjs/unplugin": "^0.19.1",
19+
"@stylexjs/unplugin": "^0.19.2",
2020
"@types/node": "^24.19.2",
2121
"@types/react": "^19.3.0",
2222
"@types/react-dom": "^19.3.0",

‎rsbuild/stylex/rsbuild.config.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineConfig } from '@rsbuild/core';
22
import { pluginReact } from '@rsbuild/plugin-react';
3-
import stylex from '@stylexjs/unplugin';
3+
import stylexPlugin from '@stylexjs/unplugin/rspack';
44

55
export default defineConfig({
66
plugins: [pluginReact()],
@@ -10,11 +10,7 @@ export default defineConfig({
1010
// Official StyleX plugin: compiles StyleX and appends CSS into the
1111
// stylesheet emitted by CssExtractRspackPlugin (used by Rsbuild).
1212
// See https://stylexjs.com/docs/learn/installation/rspack/
13-
//
14-
// Prefer the webpack adapter here: @stylexjs/unplugin currently attaches
15-
// CSS injection via the webpack() hook, which Rspack still invokes for
16-
// webpack-compatible plugins. The rspack() entry only runs transform.
17-
stylex.webpack({
13+
stylexPlugin({
1814
useCSSLayers: true,
1915
// Inject styles during development so they update with HMR.
2016
runtimeInjection: process.env.NODE_ENV === 'development',

0 commit comments

Comments
 (0)