Skip to content

Commit 20b9a91

Browse files
committed
Fix rewrite for stylesheet import
# Conflicts: # packages/uniwind-plugin-next/src/webpack/withUniwindBase.ts
1 parent 534dfc5 commit 20b9a91

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

examples/next-16/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"react-dom": "19.2.3",
1717
"react-native": "0.81",
1818
"react-native-web": "^0.21.2",
19-
"uniwind": "^1.2.4",
19+
"uniwind": "^1.2.7",
2020
"uniwind-plugin-next": "workspace:*"
2121
},
2222
"devDependencies": {

packages/uniwind-plugin-next/src/webpack/withUniwindBase.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,27 @@ export function withUniwindBase(
5050
// Inside uniwind/dist → react-native-web
5151
resource.request = "react-native-web";
5252
} else {
53-
// Everywhere else → uniwnd/web
53+
// Everywhere else → uniwind/web
5454
resource.request = `${packageName}/components/index`;
5555
}
5656
}),
5757
);
5858

59+
// Rewrite createOrderedCSSStyleSheet from react-native-web to the Uniwind version
60+
config.plugins.push(
61+
new webpack.NormalModuleReplacementPlugin(
62+
/^\.\/createOrderedCSSStyleSheet$/,
63+
(resource) => {
64+
const context = resource.context || "";
65+
66+
// Scope rewrite to react-native-web only
67+
if (context.includes("react-native-web/dist/exports/StyleSheet")) {
68+
resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;
69+
}
70+
},
71+
),
72+
);
73+
5974
config.plugins.push(new UniwindWebpackPlugin(packageName, uniwindConfig));
6075

6176
// Execute the user-defined webpack config.

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)