Skip to content

Commit f666c25

Browse files
committed
Fix rewrite for stylesheet import
1 parent c485156 commit f666c25

3 files changed

Lines changed: 16 additions & 18 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: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@ export function withUniwindBase(
3838
// Inside uniwind/dist → react-native-web
3939
resource.request = "react-native-web";
4040
} else {
41-
// Everywhere else → uniwnd/web
41+
// Everywhere else → uniwind/web
4242
resource.request = `${packageName}/components/index`;
4343
}
4444
}),
4545
);
4646

47-
// Rewrite createOrderedCSSStyleSheet from react-native-web to the uniwind version
47+
// Rewrite createOrderedCSSStyleSheet from react-native-web to the Uniwind version
4848
config.plugins.push(
49-
new NormalModuleReplacementPlugin(
50-
/react-native-web\/dist\/exports\/StyleSheet\/dom\/createCSSStyleSheet/,
51-
require.resolve(
52-
`${packageName}/components/createOrderedCSSStyleSheet`,
53-
),
49+
new webpack.NormalModuleReplacementPlugin(
50+
/^\.\/createOrderedCSSStyleSheet$/,
51+
(resource) => {
52+
const context = resource.context || "";
53+
54+
// Scope rewrite to react-native-web only
55+
if (context.includes("react-native-web/dist/exports/StyleSheet")) {
56+
resource.request = `${packageName}/components/createOrderedCSSStyleSheet`;
57+
}
58+
},
5459
),
5560
);
5661

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)