tailwind-unwind 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -1
- package/dist/{chunk-N7HD4T2I.js → chunk-FASYIEVZ.js} +583 -46
- package/dist/chunk-FASYIEVZ.js.map +1 -0
- package/dist/cli/index.js +171 -26
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +66 -2
- package/dist/index.js +7 -1
- package/package.json +3 -2
- package/tailwind-unwind.config.example.json +24 -0
- package/dist/chunk-N7HD4T2I.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# tailwind-unwind
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/tailwind-unwind)
|
|
4
|
+
|
|
3
5
|
CLI tool to analyze, extract, and refactor repeated Tailwind CSS utility patterns in React and Next.js projects.
|
|
4
6
|
|
|
5
7
|
**Repository:** [github.com/AVPletnev/tailwind-unwind](https://github.com/AVPletnev/tailwind-unwind)
|
|
@@ -23,6 +25,52 @@ npx tailwind-unwind analyze ./src
|
|
|
23
25
|
|
|
24
26
|
Requires **Node.js 18+**.
|
|
25
27
|
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Copy [`tailwind-unwind.config.example.json`](tailwind-unwind.config.example.json) to your project root:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cp node_modules/tailwind-unwind/tailwind-unwind.config.example.json tailwind-unwind.config.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Supported filenames: `tailwind-unwind.config.json`, `.tailwind-unwindrc`, `tailwind-unwind.config.js` / `.mjs` / `.cjs`.
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"include": ["src/**/*.tsx"],
|
|
41
|
+
"exclude": ["**/*.test.tsx", "**/*.stories.tsx"],
|
|
42
|
+
"names": {
|
|
43
|
+
"flex items-center justify-between p-4": "page-header",
|
|
44
|
+
"w-full h-auto object-cover rounded-lg": "media-cover"
|
|
45
|
+
},
|
|
46
|
+
"analyze": {
|
|
47
|
+
"minOccurrences": 5,
|
|
48
|
+
"top": 10
|
|
49
|
+
},
|
|
50
|
+
"generate": {
|
|
51
|
+
"minOccurrences": 3,
|
|
52
|
+
"prefix": "twu-",
|
|
53
|
+
"output": "src/styles/components.css"
|
|
54
|
+
},
|
|
55
|
+
"apply": {
|
|
56
|
+
"output": "src/styles/components.css"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| Key | Description |
|
|
62
|
+
|-----|-------------|
|
|
63
|
+
| `include` / `exclude` | Glob patterns for file scanning |
|
|
64
|
+
| `names` | Custom class names (utilities string → base name, prefix added automatically) |
|
|
65
|
+
| `analyze` / `generate` / `apply` | Per-command overrides (`minOccurrences`, `top`, `prefix`, `output`, …) |
|
|
66
|
+
|
|
67
|
+
Config is discovered from the current directory **and** ancestors of `<path>`. CLI flags override config values.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx tailwind-unwind analyze ./src --config ./tailwind-unwind.config.json
|
|
71
|
+
npx tailwind-unwind generate ./src --include "src/components/**/*.tsx"
|
|
72
|
+
```
|
|
73
|
+
|
|
26
74
|
## Quick start
|
|
27
75
|
|
|
28
76
|
```bash
|
|
@@ -57,6 +105,9 @@ npx tailwind-unwind analyze <path>
|
|
|
57
105
|
| `--top <n>` | `10` | Number of top combinations to show |
|
|
58
106
|
| `--format <type>` | `console` | Output format: `console` or `json` |
|
|
59
107
|
| `--no-dedupe-subsets` | — | Include subset combinations in results |
|
|
108
|
+
| `--config <file>` | — | Path to config file |
|
|
109
|
+
| `--include <patterns>` | all `src` | Comma-separated glob include patterns |
|
|
110
|
+
| `--exclude <patterns>` | — | Comma-separated glob exclude patterns |
|
|
60
111
|
|
|
61
112
|
```bash
|
|
62
113
|
# JSON report for CI
|
|
@@ -80,6 +131,7 @@ Unique class combinations: 89
|
|
|
80
131
|
1. "flex items-center justify-between p-4"
|
|
81
132
|
Occurrences: 24
|
|
82
133
|
Suggestion: .page-header
|
|
134
|
+
Extractable: yes — use generate/apply
|
|
83
135
|
Found in: src/components/Header.tsx:12, src/layout/Toolbar.tsx:5 (+18 more)
|
|
84
136
|
|
|
85
137
|
💡 Potential code reduction: 38%
|
|
@@ -193,7 +245,18 @@ Generated classes use a **`twu-` prefix** by default to avoid conflicts with exi
|
|
|
193
245
|
| `grid grid-cols-3 gap-4` | `twu-card-grid` |
|
|
194
246
|
| `fixed inset-0 bg-black/50` | `twu-backdrop` |
|
|
195
247
|
|
|
196
|
-
Customize with `--prefix app-`
|
|
248
|
+
Customize with `--prefix app-` or the `names` field in config:
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"names": {
|
|
253
|
+
"flex items-center justify-between p-4": "page-header"
|
|
254
|
+
},
|
|
255
|
+
"generate": { "prefix": "app-" }
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
→ `.app-page-header`
|
|
197
260
|
|
|
198
261
|
---
|
|
199
262
|
|