Skip to content

Commit 56e30d7

Browse files
authored
docs(react): adjust Tailwind guide for React (#6386)
1 parent f86a073 commit 56e30d7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

nx-dev/nx-dev/public/documentation/latest/react/guides/using-tailwind-css-in-react.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ This creates the needed files with a general boilerplate implementation.
2828
Next, adjust the `postcss.config.js` as follows:
2929

3030
```js
31+
const { join } = require('path');
32+
3133
module.exports = {
3234
plugins: {
33-
tailwindcss: { config: './apps/{your app here}/tailwind.config.js' },
35+
tailwindcss: {
36+
config: join(__dirname, 'tailwind.config.js'),
37+
},
3438
autoprefixer: {},
3539
},
3640
};
@@ -43,10 +47,15 @@ In a typical `tailwind.config.js` file, the `purge` property of the tailwind con
4347
Nx has a utility function for determining the glob representation of all files the application depends on (based on the Nx Dependency Graph), which should be used when setting this purge property. This eliminates additional manual maintenance as your workspace progresses.
4448

4549
```js
50+
const { join } = require('path');
4651
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
4752

4853
module.exports = {
49-
purge: createGlobPatternsForDependencies(__dirname),
54+
purge: [
55+
// place your own app's glob pattern (for example)
56+
join(__dirname, '**/*.{js,ts,jsx,tsx}'),
57+
...createGlobPatternsForDependencies(__dirname),
58+
],
5059
darkMode: false, // or 'media' or 'class'
5160
theme: {
5261
extend: {},
@@ -58,6 +67,8 @@ module.exports = {
5867
};
5968
```
6069

70+
`createGlobPatternsForDependencies(..)` uses the Nx dependency graph to generate glob patterns for all the app's **dependencies** (e.g. for all referenced libraries within the Nx workspace).
71+
6172
_NOTE:_ To ensure proper purging for custom configurations, be sure that the `NODE_ENV` environment variable is set to `production`. By default, Nx only purges on prod build (for example: `nx build --prod`).
6273

6374
## Step 3: Import TailwindCss Styles

0 commit comments

Comments
 (0)