Skip to content

Commit 5849edb

Browse files
authored
docs: add options.exclude and options.include (#20)
1 parent f02a9f1 commit 5849edb

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,43 @@ export default {
109109
};
110110
```
111111

112+
### `exclude` / `include`
113+
114+
- Type: `ReadonlyArray<string | RegExp> | string | RegExp | null | undefined`
115+
- Default: `undefined`
116+
117+
These two options are used to filter which module to be processed by Tailwind CSS using [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) pattern.
118+
119+
If `include` is omitted or empty, all modules that do not match any of the `exclude` patterns will be included.
120+
Otherwise, only modules that match one or more of the `include` patterns and do not match any of the `exclude` patterns will be included.
121+
122+
- Example:
123+
124+
Include all `.js`, `.jsx`, `.ts`, `.tsx` files but exclude files in `./src/store` and `node_modules`:
125+
126+
```js
127+
// rsbuild.config.ts
128+
import { pluginTailwindCSS } from "@byted-lynx/plugin-tailwindcss";
129+
130+
export default {
131+
plugins: [
132+
pluginTailwindCSS({
133+
include: /\.[jt]sx?/,
134+
exclude: ["./src/store/**", /[\\/]node_modules[\\/]/],
135+
}),
136+
],
137+
};
138+
```
139+
140+
Note that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.
141+
112142
## Credits
113143

114144
Thanks to:
115145

116146
- [Tailwind CSS V4](https://tailwindcss.com/blog/tailwindcss-v4-alpha) for the idea of purge CSS by module graph.
117147
- The [purge-tailwind-plugin](https://github.com/hardfist/purge-tailwind-plugin) created by [@hardfist](https://github.com/hardfist) for the implementation of the Rspack plugin.
148+
- The [Rollup](https://github.com/rollup/) project created by [Rich Harris](https://github.com/Rich-Harris) and maintained by [Lukas Taegert-Atkinson](https://github.com/lukastaegert) for the implementaion of `exclude` and `include`.
118149

119150
## License
120151

0 commit comments

Comments
 (0)