{"id":20097511,"url":"https://github.com/rspack-contrib/rsbuild-plugin-tailwindcss","last_synced_at":"2025-04-14T10:13:52.894Z","repository":{"id":262668215,"uuid":"885128921","full_name":"rspack-contrib/rsbuild-plugin-tailwindcss","owner":"rspack-contrib","description":"An Rsbuild plugin to integrate with Tailwind CSS V3","archived":false,"fork":false,"pushed_at":"2025-04-04T19:02:17.000Z","size":233,"stargazers_count":42,"open_issues_count":8,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-14T10:13:46.405Z","etag":null,"topics":["rsbuild","rsbuild-plugin","rspack","tailwindcss"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rspack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T02:22:16.000Z","updated_at":"2025-04-13T09:35:01.000Z","dependencies_parsed_at":"2024-11-13T17:03:15.699Z","dependency_job_id":"e94e5568-ddc4-4d89-a57d-4c6259b5e958","html_url":"https://github.com/rspack-contrib/rsbuild-plugin-tailwindcss","commit_stats":null,"previous_names":["rspack-contrib/rsbuild-plugin-tailwindcss"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-tailwindcss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-tailwindcss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-tailwindcss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Frsbuild-plugin-tailwindcss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/rsbuild-plugin-tailwindcss/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860167,"owners_count":21173342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rsbuild","rsbuild-plugin","rspack","tailwindcss"],"created_at":"2024-11-13T17:01:14.283Z","updated_at":"2025-04-14T10:13:52.881Z","avatar_url":"https://github.com/rspack-contrib.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Rsbuild Plugins"],"readme":"# rsbuild-plugin-tailwindcss\n\nAn Rsbuild plugin to integrate with [Tailwind CSS](https://tailwindcss.com/) V3.\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/rsbuild-plugin-tailwindcss\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/rsbuild-plugin-tailwindcss?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n  \u003ca href=\"https://npmcharts.com/compare/rsbuild-plugin-tailwindcss?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/rsbuild-plugin-tailwindcss.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"downloads\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Why?\n\nTailwind CSS is able to remove unused CSS classes through [Content Configuration](https://tailwindcss.com/docs/content-configuration). However, its accuracy may be insufficient when:\n\n- Using multiple entries\n- Using a Tailwind CSS-based component library\n\nThis plugin uses the Rspack module graph to override the `content` configuration with imported modules, generating Tailwind CSS output _**based on usage**_.\n\n## Usage\n\nInstall:\n\n```bash\nnpm add tailwindcss@3 rsbuild-plugin-tailwindcss -D\n```\n\nAdd plugin to your `rsbuild.config.ts`:\n\n```ts\n// rsbuild.config.ts\nimport { pluginTailwindCSS } from \"rsbuild-plugin-tailwindcss\";\n\nexport default {\n  plugins: [pluginTailwindCSS()],\n};\n```\n\n### Custom Tailwind CSS Configuration\n\nCreate a `tailwind.config.js` file at the root of the project:\n\n```js\n/** @type {import('tailwindcss').Config} */\nexport default {\n  theme: {\n    colors: {\n      blue: \"#1fb6ff\",\n      purple: \"#7e5bef\",\n      pink: \"#ff49db\",\n      orange: \"#ff7849\",\n      green: \"#13ce66\",\n      yellow: \"#ffc82c\",\n      \"gray-dark\": \"#273444\",\n      gray: \"#8492a6\",\n      \"gray-light\": \"#d3dce6\",\n    },\n  },\n};\n```\n\nThis will be auto-loaded by Rsbuild and applied by `rsbuild-plugin-tailwindcss`.\n\n\u003e [!NOTE]\n\u003e\n\u003e You don't need to add `content` in the `tailwind.config.js`. `rsbuild-plugin-tailwindcss` will add the imported modules for you.\n\n### Custom PostCSS Options\n\nCreate a `postcss.config.js` file at the root of the project:\n\n```js\nexport default {\n  plugins: {\n    cssnano: process.env[\"NODE_ENV\"] === \"production\" ? {} : false,\n  },\n};\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e You don't need to add `tailwindcss` in the `postcss.config.js`. `rsbuild-plugin-tailwindcss` will add the plugin for you.\n\nOr use the [`tools.postcss`](https://rsbuild.dev/config/tools/postcss) option in `rsbuild.config.ts`.\n\n## Options\n\n### `config`\n\n- Type: `string | undefined`\n- Default: `tailwind.config.js`\n\nThe path to custom Tailwind CSS configuration. Could be a relative path from the root of the project or an absolute path.\n\n- Example:\n\n```js\n// rsbuild.config.ts\nimport { pluginTailwindCSS } from \"rsbuild-plugin-tailwindcss\";\n\nexport default {\n  plugins: [\n    pluginTailwindCSS({\n      config: \"./config/tailwind.config.js\",\n    }),\n  ],\n};\n```\n\n### `exclude` / `include`\n\n- Type: `ReadonlyArray\u003cstring | RegExp\u003e | string | RegExp | null | undefined`\n- Default: `undefined`\n\nThese two options are used to filter which module to be processed by Tailwind CSS using [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) pattern.\n\nIf `include` is omitted or empty, all modules that do not match any of the `exclude` patterns will be included.\nOtherwise, only modules that match one or more of the `include` patterns and do not match any of the `exclude` patterns will be included.\n\n- Example:\n\nInclude all `.js`, `.jsx`, `.ts`, `.tsx` files but exclude files in `./src/store` and `node_modules`:\n\n```js\n// rsbuild.config.ts\nimport { pluginTailwindCSS } from \"@byted-lynx/plugin-tailwindcss\";\n\nexport default {\n  plugins: [\n    pluginTailwindCSS({\n      include: /\\.[jt]sx?/,\n      exclude: [\"./src/store/**\", /[\\\\/]node_modules[\\\\/]/],\n    }),\n  ],\n};\n```\n\nNote 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.\n\n## Debugging\n\nUse `DEBUG='rsbuild'` to enable debugging mode for the plugin. When debugging is enabled, the plugin will:\n\n1. Save the generated Tailwind CSS configuration files in the `.rsbuild/\u003centry-name\u003e` directory inside your project's output path.\n2. Generate readable configuration files that include all modules being processed by Tailwind CSS.\n\nThis is helpful for:\n\n- Inspecting which modules are included in the Tailwind CSS content scanning\n- Troubleshooting issues with CSS purging\n- Understanding how the plugin is generating configurations for each entry point\n\nExample:\n\n```bash\n# For macOS/Linux\nDEBUG=rsbuild npm run build\n\n# For Windows (cmd)\nset DEBUG=rsbuild \u0026\u0026 npm run build\n\n# For Windows (PowerShell)\n$env:DEBUG=\"rsbuild\"; npm run build\n```\n\nYou can also use more specific debug patterns:\n\n- `DEBUG=rsbuild:tailwind` - Debug only the Tailwind CSS plugin\n- `DEBUG=rsbuild:*` - Debug all Rsbuild plugins\n- `DEBUG=*` - Debug everything\n\n## Credits\n\nThanks to:\n\n- [Tailwind CSS V4](https://tailwindcss.com/blog/tailwindcss-v4-alpha) for the idea of purge CSS by module graph.\n- 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.\n- 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`.\n\n## License\n\n[MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-tailwindcss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-tailwindcss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Frsbuild-plugin-tailwindcss/lists"}