You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add plugin option documentation to the postcss plugin readme (#18940)
Closestailwindlabs/tailwindcss.com#2061
In lieu of finding a place to put this on the docs we can at least
document this in the readme for the plugin.
---------
Co-authored-by: Philipp Spiess <[email protected]>
Copy file name to clipboardExpand all lines: packages/@tailwindcss-postcss/README.md
+90Lines changed: 90 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,3 +34,93 @@ For help, discussion about best practices, or feature ideas:
34
34
## Contributing
35
35
36
36
If you're interested in contributing to Tailwind CSS, please read our [contributing docs](https://github.com/tailwindcss/tailwindcss/blob/next/.github/CONTRIBUTING.md)**before submitting a pull request**.
37
+
38
+
---
39
+
40
+
## `@tailwindcss/postcss` plugin API
41
+
42
+
### Changing where the plugin searches for source files
43
+
44
+
You can use the `base` option (defaults to the current working directory) to change the directory in which the plugin searches for source files:
45
+
46
+
```js
47
+
importtailwindcssfrom"@tailwindcss/postcss"
48
+
49
+
exportdefault {
50
+
plugins: [
51
+
tailwindcss({
52
+
base:path.resolve(__dirname, "./path)
53
+
})
54
+
]
55
+
}
56
+
```
57
+
58
+
### Enabling or disabling Lightning CSS
59
+
60
+
By default, this plugin detects whether or not the CSS is being built for production by checking the `NODE_ENV` environment variable. When building for production Lightning CSS will be enabled otherwise it is disabled.
61
+
62
+
If you want to always enable or disable Lightning CSS the `optimize` option may be used:
63
+
64
+
```js
65
+
import tailwindcss from "@tailwindcss/postcss"
66
+
67
+
export default {
68
+
plugins: [
69
+
tailwindcss({
70
+
// Enable or disable Lightning CSS
71
+
optimize: false,
72
+
})
73
+
]
74
+
}
75
+
```
76
+
77
+
It's also possible to keep Lightning CSS enabled but disable minification:
78
+
79
+
```js
80
+
import tailwindcss from "@tailwindcss/postcss"
81
+
82
+
export default {
83
+
plugins: [
84
+
tailwindcss({
85
+
optimize: { minify: false },
86
+
})
87
+
]
88
+
}
89
+
```
90
+
91
+
### Enabling or disabling `url(…)` rewriting
92
+
93
+
Our PostCSS plugin can rewrite `url(…)`s for you since it also handles `@import` (no `postcss-import` is needed). This feature is enabled by default.
94
+
95
+
In some situations the bundler or framework you're using may provide this feature itself. In this case you can set `transformAssetUrls` to `false` to disable this feature:
96
+
97
+
```js
98
+
import tailwindcss from "@tailwindcss/postcss"
99
+
100
+
export default {
101
+
plugins: [
102
+
tailwindcss({
103
+
// Disable `url(…)` rewriting
104
+
transformAssetUrls: false,
105
+
106
+
// Enable `url(…)` rewriting (the default)
107
+
transformAssetUrls: true,
108
+
})
109
+
]
110
+
}
111
+
```
112
+
113
+
You may also pass options to `optimize` to enable Lighting CSS but prevent minification:
114
+
115
+
```js
116
+
import tailwindcss from "@tailwindcss/postcss"
117
+
118
+
export default {
119
+
plugins: [
120
+
tailwindcss({
121
+
// Enables Lightning CSS but disables minification
0 commit comments