tailwindcss-patch 7.1.5 → 8.0.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 +87 -73
- package/dist/chunk-FSTUQMKT.js +1320 -0
- package/dist/chunk-Y45IACSP.mjs +1316 -0
- package/dist/cli.js +131 -38
- package/dist/cli.mjs +132 -38
- package/dist/index.d.mts +237 -87
- package/dist/index.d.ts +237 -87
- package/dist/index.js +6 -2
- package/dist/index.mjs +19 -15
- package/package.json +20 -20
- package/dist/chunk-N2DIY7M3.js +0 -1107
- package/dist/chunk-NS2I2YPX.mjs +0 -1102
package/README.md
CHANGED
|
@@ -1,121 +1,135 @@
|
|
|
1
1
|
# tailwindcss-patch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modern tooling to patch Tailwind CSS, capture runtime contexts, and materialise every class that Tailwind can generate. The package now ships with a redesigned architecture focused on clarity, predictable configuration, and first-class Tailwind v4 support.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [Cli](#cli)
|
|
10
|
-
- [Extract all class into a json](#extract-all-class-into-a-json)
|
|
11
|
-
- [Nodejs API](#nodejs-api)
|
|
12
|
-
- [Config](#config)
|
|
13
|
-
- [Init Config File](#init-config-file)
|
|
14
|
-
- [What's next?](#whats-next)
|
|
5
|
+
- Export runtime contexts for Tailwind v2/v3 without editing source files manually.
|
|
6
|
+
- Traverse Tailwind v4 projects by scanning CSS outputs and content sources.
|
|
7
|
+
- Write class inventories to disk or keep them in memory for tooling integrations.
|
|
8
|
+
- Control caching, filtering, and custom unit extensions from a single, typed entrypoint.
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
## Installation
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Setup
|
|
23
|
-
|
|
24
|
-
1. Install package
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
<yarn|npm|pnpm> add -D tailwindcss-patch
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. Patch tailwindcss
|
|
31
|
-
|
|
32
|
-
```sh
|
|
33
|
-
npx tw-patch install
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add -D tailwindcss-patch
|
|
14
|
+
pnpm dlx tw-patch install
|
|
34
15
|
```
|
|
35
16
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`package.json`
|
|
17
|
+
Keep the patch applied after installs by adding a `prepare` hook:
|
|
39
18
|
|
|
40
19
|
```json
|
|
41
20
|
{
|
|
42
|
-
/* ... */
|
|
43
21
|
"scripts": {
|
|
44
22
|
"prepare": "tw-patch install"
|
|
45
23
|
}
|
|
46
24
|
}
|
|
47
25
|
```
|
|
48
26
|
|
|
49
|
-
## Usage
|
|
27
|
+
## CLI Usage
|
|
50
28
|
|
|
51
|
-
|
|
29
|
+
Run the CLI through `tw-patch` (or `tailwindcss-patch`) from your project root.
|
|
52
30
|
|
|
53
|
-
|
|
31
|
+
```bash
|
|
32
|
+
# Apply runtime patches to the local Tailwind installation
|
|
33
|
+
pnpm dlx tw-patch install
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
# Extract all classes into the configured output file
|
|
36
|
+
pnpm dlx tw-patch extract
|
|
57
37
|
```
|
|
58
38
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
you can custom this behavior by config `tailwindcss-mangle.config.ts`
|
|
39
|
+
### Extract options
|
|
62
40
|
|
|
63
|
-
|
|
41
|
+
| Flag | Description |
|
|
42
|
+
| ------------------------ | ---------------------------------------------------------------- |
|
|
43
|
+
| `--cwd <dir>` | Use a different working directory when loading configuration. |
|
|
44
|
+
| `--output <file>` | Override the target file for the generated class list. |
|
|
45
|
+
| `--format <json\|lines>` | Switch between JSON output (default) and newline-delimited text. |
|
|
46
|
+
| `--css <file>` | Provide a CSS entry file when working with Tailwind v4 projects. |
|
|
47
|
+
| `--no-write` | Skip writing to disk and only return the collected classes. |
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
import { TailwindcssPatcher } from 'tailwindcss-patch'
|
|
49
|
+
The CLI loads `tailwindcss-patch.config.ts` via `@tailwindcss-mangle/config`. Legacy configs continue to work; see the [migration guide](./MIGRATION.md) for hints on the new fields.
|
|
67
50
|
|
|
68
|
-
|
|
69
|
-
// do patch
|
|
70
|
-
twPatcher.patch()
|
|
71
|
-
// get all contexts at runtime
|
|
72
|
-
twPatcher.getContexts()
|
|
73
|
-
// get all class generated by tailwindcss utilities
|
|
74
|
-
twPatcher.getClassSet()
|
|
75
|
-
```
|
|
51
|
+
## Programmatic API
|
|
76
52
|
|
|
77
|
-
|
|
53
|
+
```ts
|
|
54
|
+
import { TailwindcssPatcher } from 'tailwindcss-patch'
|
|
78
55
|
|
|
79
|
-
|
|
56
|
+
const patcher = new TailwindcssPatcher({
|
|
57
|
+
overwrite: true,
|
|
58
|
+
cache: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
dir: '.tw-patch/cache',
|
|
61
|
+
strategy: 'merge',
|
|
62
|
+
},
|
|
63
|
+
output: {
|
|
64
|
+
file: '.tw-patch/tw-class-list.json',
|
|
65
|
+
format: 'json',
|
|
66
|
+
},
|
|
67
|
+
features: {
|
|
68
|
+
exposeContext: { refProperty: 'runtimeContexts' },
|
|
69
|
+
extendLengthUnits: {
|
|
70
|
+
units: ['rpx'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
tailwind: {
|
|
74
|
+
version: 4,
|
|
75
|
+
v4: {
|
|
76
|
+
base: './src',
|
|
77
|
+
cssEntries: ['dist/tailwind.css'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
})
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
await patcher.patch()
|
|
83
|
+
const { classList, filename } = await patcher.extract()
|
|
83
84
|
```
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
The constructor accepts either the new object shown above or the historical `patch`/`cache` shape. Conversions happen internally so existing configs remain backwards compatible.
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
### Helper utilities
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
- `normalizeOptions` – normalise raw user input to the runtime shape.
|
|
91
|
+
- `CacheStore` – read/write class caches respecting merge or overwrite semantics.
|
|
92
|
+
- `extractValidCandidates` – scan Tailwind v4 CSS/content sources with the Tailwind Oxide scanner.
|
|
93
|
+
- `runTailwindBuild` – run the Tailwind PostCSS plugin for v2/v3 projects to prime runtime contexts.
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
```
|
|
95
|
+
All helpers are exported from the package root for direct consumption in custom tooling.
|
|
94
96
|
|
|
95
|
-
|
|
97
|
+
## Configuration Example
|
|
96
98
|
|
|
97
99
|
```ts
|
|
100
|
+
// tailwindcss-patch.config.ts
|
|
98
101
|
import { defineConfig } from 'tailwindcss-patch'
|
|
99
102
|
|
|
100
103
|
export default defineConfig({
|
|
101
104
|
patch: {
|
|
102
105
|
output: {
|
|
103
|
-
filename: '
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
filename: '.tw-patch/tw-class-list.json',
|
|
107
|
+
removeUniversalSelector: true,
|
|
108
|
+
format: 'json',
|
|
106
109
|
},
|
|
107
110
|
tailwindcss: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
version: 4,
|
|
112
|
+
v4: {
|
|
113
|
+
cssEntries: ['dist/tailwind.css'],
|
|
114
|
+
sources: [{ base: 'src', pattern: '**/*.{html,tsx}', negated: false }],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
applyPatches: {
|
|
118
|
+
exportContext: true,
|
|
119
|
+
extendLengthUnits: {
|
|
120
|
+
units: ['rpx'],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
112
124
|
})
|
|
113
125
|
```
|
|
114
126
|
|
|
115
|
-
|
|
127
|
+
Even though `defineConfig` still exposes the historical shape, every new option is supported and will be normalised automatically.
|
|
128
|
+
|
|
129
|
+
## Migration
|
|
116
130
|
|
|
117
|
-
|
|
131
|
+
Breaking changes, module moves, and upgrade paths are documented in [MIGRATION.md](./MIGRATION.md). Review it when updating from tailwindcss-patch v7.x or earlier.
|
|
118
132
|
|
|
119
|
-
|
|
133
|
+
## License
|
|
120
134
|
|
|
121
|
-
|
|
135
|
+
MIT © ice breaker
|