Skip to content

Commit

Permalink
docs: add options.exclude and options.include (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinaaa authored Nov 23, 2024
1 parent f02a9f1 commit 5849edb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,43 @@ export default {
};
```

### `exclude` / `include`

- Type: `ReadonlyArray<string | RegExp> | string | RegExp | null | undefined`
- Default: `undefined`

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.

If `include` is omitted or empty, all modules that do not match any of the `exclude` patterns will be included.
Otherwise, only modules that match one or more of the `include` patterns and do not match any of the `exclude` patterns will be included.

- Example:

Include all `.js`, `.jsx`, `.ts`, `.tsx` files but exclude files in `./src/store` and `node_modules`:

```js
// rsbuild.config.ts
import { pluginTailwindCSS } from "@byted-lynx/plugin-tailwindcss";

export default {
plugins: [
pluginTailwindCSS({
include: /\.[jt]sx?/,
exclude: ["./src/store/**", /[\\/]node_modules[\\/]/],
}),
],
};
```

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.

## Credits

Thanks to:

- [Tailwind CSS V4](https://tailwindcss.com/blog/tailwindcss-v4-alpha) for the idea of purge CSS by module graph.
- 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.
- 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`.

## License

Expand Down

0 comments on commit 5849edb

Please sign in to comment.