Skip to content

Commit 9793a50

Browse files
authored
docs: add documentation for NativeWind plugin (#1180)
1 parent 7437d92 commit 9793a50

File tree

3 files changed

+101
-6
lines changed

3 files changed

+101
-6
lines changed

packages/plugin-nativewind/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ This plugin seamlessly integrates NativeWind with Re.Pack's build process by:
2323

2424
## Installation
2525

26-
First, follow these steps from the official [NativeWind installation guide](https://www.nativewind.dev/getting-started/react-native):
26+
First, follow these steps from the official [NativeWind installation guide](https://www.nativewind.dev/docs/getting-started/installation):
2727

28-
1. [Install NativeWind](https://www.nativewind.dev/getting-started/react-native#installation)
29-
2. [Setup Tailwind CSS](https://www.nativewind.dev/getting-started/react-native#2-setup-tailwind-css)
30-
3. [Import your CSS file](https://www.nativewind.dev/getting-started/react-native#5-import-your-css-file)
31-
4. (Optional) [Setup TypeScript support](https://www.nativewind.dev/getting-started/typescript)
28+
1. [Install NativeWind](https://www.nativewind.dev/docs/getting-started/installation#1-install-nativewind)
29+
2. [Setup Tailwind CSS](https://www.nativewind.dev/docs/getting-started/installation#2-setup-tailwind-css)
30+
3. [Import your CSS file](https://www.nativewind.dev/docs/getting-started/installation#5-import-your-css-file)
31+
4. (Optional) [Setup TypeScript support](https://www.nativewind.dev/docs/getting-started/installation#7-typescript-setup-optional)
3232

3333
Then install the Re.Pack NativeWind plugin and it's dependencies:
3434

website/src/latest/docs/features/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"dev-server",
55
"flow-support",
66
"devtools",
7-
"reanimated"
7+
"reanimated",
8+
"nativewind"
89
]
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { PackageManagerTabs } from 'rspress/theme';
2+
3+
# NativeWind
4+
5+
[NativeWind](https://www.nativewind.dev/) brings Tailwind CSS utility classes to React Native, enabling rapid, consistent styling. With Re.Pack, you can seamlessly integrate NativeWind through a dedicated plugin.
6+
7+
[@callstack/repack-plugin-nativewind](https://github.com/callstack/repack/tree/main/packages/plugin-nativewind) is a plugin for Re.Pack that enables integrating NativeWind into your React Native projects.
8+
9+
## About
10+
11+
This plugin seamlessly integrates NativeWind with Re.Pack's build process by:
12+
13+
- Configuring PostCSS and Tailwind CSS processing for your stylesheets
14+
- Handling conversion of CSS to React Native-compatible styles
15+
- Setting up proper SWC transformations for NativeWind's JSX runtime
16+
17+
## Installation
18+
19+
First, follow these steps from the official [NativeWind installation guide](https://www.nativewind.dev/docs/getting-started/installation):
20+
21+
1. [Install NativeWind](https://www.nativewind.dev/docs/getting-started/installation#1-install-nativewind)
22+
2. [Setup Tailwind CSS](https://www.nativewind.dev/docs/getting-started/installation#2-setup-tailwind-css)
23+
3. [Import your CSS file](https://www.nativewind.dev/docs/getting-started/installation#5-import-your-css-file)
24+
4. (Optional) [Setup TypeScript support](https://www.nativewind.dev/docs/getting-started/installation#7-typescript-setup-optional)
25+
26+
Then install the Re.Pack NativeWind plugin and its dependencies:
27+
28+
<PackageManagerTabs command="install -D @callstack/repack-plugin-nativewind postcss postcss-loader autoprefixer" />
29+
30+
:::tip Version Alignment
31+
The NativeWind plugin is versioned together with Re.Pack. For best compatibility, align the version of `@callstack/repack-plugin-nativewind` with your `@callstack/repack` version in the project.
32+
:::
33+
34+
:::info{title="A note on dependencies:"}
35+
These additional dependencies (`postcss`, `postcss-loader`, and `autoprefixer`) are required for processing Tailwind CSS with Webpack/Rspack, as specified in the [official Tailwind CSS Rspack guide](https://tailwindcss.com/docs/guides/rspack). They enable PostCSS processing and autoprefixing of CSS styles in your build pipeline.
36+
:::
37+
38+
## Usage
39+
40+
:::info{title="Webpack specific configuration"}
41+
If you are using Webpack (not Rspack), you need to add the following configuration to your `babel.config.js`:
42+
43+
```js title="babel.config.js"
44+
plugins: [
45+
[
46+
'@babel/plugin-transform-react-jsx',
47+
{
48+
runtime: 'automatic',
49+
importSource: 'nativewind',
50+
},
51+
],
52+
],
53+
```
54+
:::
55+
56+
### Plugin
57+
58+
To add the plugin to your Re.Pack configuration, update your `rspack.config.js` or `webpack.config.js` as follows:
59+
60+
```js title="rspack.config.js"
61+
import { NativeWindPlugin } from "@callstack/repack-plugin-nativewind";
62+
63+
export default (env) => {
64+
// ...
65+
return {
66+
// ...
67+
plugins: [
68+
// ...
69+
new NativeWindPlugin(),
70+
],
71+
};
72+
};
73+
```
74+
75+
## Troubleshooting
76+
77+
- **Styles not applying?**
78+
79+
Ensure your CSS import is present and the plugin is added to your config.
80+
81+
- **PostCSS errors?**
82+
83+
Double-check that all required dependencies are installed and your `postcss.config.js` is set up.
84+
85+
- **TypeScript issues?**
86+
87+
Follow the [NativeWind TypeScript setup guide](https://www.nativewind.dev/getting-started/typescript).
88+
89+
## Further Resources
90+
91+
- [NativeWind Documentation](https://www.nativewind.dev/docs)
92+
- [Tailwind CSS Documentation](https://tailwindcss.com/)
93+
- [Re.Pack NativeWind Plugin Repo](https://github.com/callstack/repack/tree/main/packages/plugin-nativewind)
94+

0 commit comments

Comments
 (0)