Skip to content

Commit 9983efc

Browse files
committed
Add note about postcss-preset-env
1 parent ee46d2f commit 9983efc

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/pages/docs/using-with-preprocessors.mdx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,16 @@ The `postcss-import` plugin is smart enough to look for files in the `node_modul
122122

123123
### Nesting
124124

125-
To add support for nested declarations, we recommend [@tailwindcss/nesting](https://github.com/tailwindlabs/tailwindcss-nesting), which is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands custom syntax like `@apply` and `@screen`.
125+
To add support for nested declarations, we recommend our bundled `tailwindcss/nesting` plugin, which is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
126126

127-
To use it, install it via npm:
128-
129-
```shell
130-
npm install @tailwindcss/nesting
131-
```
132-
133-
Then add it to your PostCSS configuration, somewhere before Tailwind itself:
127+
It's included directly in the `tailwindcss` package itself, so to use it all you need to do is add it to your PostCSS configuration, somewhere before Tailwind:
134128

135129
```js
136130
// postcss.config.js
137131
module.exports = {
138132
plugins: [
139133
require('postcss-import'),
140-
require('@tailwindcss/nesting'),
134+
require('tailwindcss/nesting'),
141135
require('tailwindcss'),
142136
require('autoprefixer'),
143137
]
@@ -146,28 +140,43 @@ module.exports = {
146140

147141
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](/docs/plugins#css-in-js-syntax).
148142

149-
If you'd rather use [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside `@tailwindcss/nesting`:
143+
If you'd rather use [postcss-nesting](https://github.com/jonathantneal/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin:
150144

151145
```shell
152-
npm install @tailwindcss/nesting postcss-nesting
146+
npm install postcss-nesting
153147
```
154148

155-
Then pass the plugin itself as an argument to `@tailwindcss/nesting` in your PostCSS configuration:
149+
Then pass the plugin itself as an argument to `tailwindcss/nesting` in your PostCSS configuration:
156150

157151
```js
158152
// postcss.config.js
159153
module.exports = {
160154
plugins: [
161155
require('postcss-import'),
162-
require('@tailwindcss/nesting')(require('postcss-nesting')),
156+
require('tailwindcss/nesting')(require('postcss-nesting')),
163157
require('tailwindcss'),
164158
require('autoprefixer'),
165159
]
166160
}
167161
```
168162

169-
This can also be helpful if for whatever reason you need to use a very specific version of `postcss-nested` and want to override the version we bundle with `@tailwindcss/nesting` itself.
163+
This can also be helpful if for whatever reason you need to use a very specific version of `postcss-nested` and want to override the version we bundle with `tailwindcss/nesting` itself.
164+
165+
Note that if you are using [`postcss-preset-env`](https://github.com/csstools/postcss-preset-env) in your project, you should make sure to disable nesting and let `tailwindcss/nesting` handle it for you instead:
170166

167+
```js
168+
// postcss.config.js
169+
module.exports = {
170+
plugins: [
171+
require('postcss-import'),
172+
require('tailwindcss/nesting')(require('postcss-nesting')),
173+
require('tailwindcss'),
174+
require('postcss-preset-env')({
175+
features: { 'nesting-rules': false }
176+
}),
177+
]
178+
}
179+
```
171180

172181
### Variables
173182

0 commit comments

Comments
 (0)