tailwindcss-patch 2.1.0 → 2.1.1

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.
Files changed (2) hide show
  1. package/README.md +48 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,17 @@
1
1
  # tailwindcss-patch
2
2
 
3
+ \[[中文(zh-cn)](./README-cn.md)\]
4
+
3
5
  get tailwindcss context at runtime ! extract all classes into file!
4
6
 
5
7
  - [tailwindcss-patch](#tailwindcss-patch)
6
8
  - [Setup](#setup)
7
9
  - [Usage](#usage)
8
10
  - [Cli](#cli)
9
- - [Init Config File](#init-config-file)
10
11
  - [Extract all class into a json](#extract-all-class-into-a-json)
11
- - [Nodejs](#nodejs)
12
+ - [Nodejs API](#nodejs-api)
13
+ - [Config](#config)
14
+ - [Init Config File](#init-config-file)
12
15
  - [Migration form v1 to v2](#migration-form-v1-to-v2)
13
16
  - [0. cli command change](#0-cli-command-change)
14
17
  - [1. default remove `*` in json array result](#1-default-remove--in-json-array-result)
@@ -20,7 +23,7 @@ get tailwindcss context at runtime ! extract all classes into file!
20
23
  1. Install package
21
24
 
22
25
  ```sh
23
- <yarn|npm|pnpm> add -D ts-patch
26
+ <yarn|npm|pnpm> add -D tailwindcss-patch
24
27
  ```
25
28
 
26
29
  2. Patch tailwindcss
@@ -46,36 +49,68 @@ npx tw-patch install
46
49
 
47
50
  ## Cli
48
51
 
49
- ### Init Config File
50
-
51
- ```sh
52
- tw-patch init
53
- ```
54
-
55
- Then there will be a ts file called `tailwindcss-mangle.config.ts` exist in your `cwd`.
56
-
57
52
  ### Extract all class into a json
58
53
 
59
54
  ```sh
60
- tw-patch extract
55
+ npx tw-patch extract
61
56
  ```
62
57
 
63
58
  default there will be a json in `.tw-patch/tw-class-list.json` in your project.
64
59
 
65
60
  you can custom this behavior by config `tailwindcss-mangle.config.ts`
66
61
 
67
- ### Nodejs
62
+ ## Nodejs API
68
63
 
69
64
  ```js
70
65
  import { TailwindcssPatcher } from 'tailwindcss-patch'
71
66
 
72
67
  const twPatcher = new TailwindcssPatcher(/* options */)
68
+ // do patch
69
+ twPatcher.patch()
73
70
  // get all contexts at runtime
74
71
  twPatcher.getContexts()
75
72
  // get all class generated by tailwindcss utilities
76
73
  twPatcher.getClassSet()
77
74
  ```
78
75
 
76
+ ## Config
77
+
78
+ ### Init Config File
79
+
80
+ ```sh
81
+ npx tw-patch init
82
+ ```
83
+
84
+ Then there will be a ts file called `tailwindcss-mangle.config.ts` exist in your `cwd`.
85
+
86
+ The config as follows:
87
+
88
+ ```ts
89
+ import { defineConfig } from 'tailwindcss-patch'
90
+
91
+ export default defineConfig({})
92
+ ```
93
+
94
+ you can custom `tw-patch` behavior by `patch` option:
95
+
96
+ ```ts
97
+ import { defineConfig } from 'tailwindcss-patch'
98
+
99
+ export default defineConfig({
100
+ patch: {
101
+ output: {
102
+ filename: 'xxx.json',
103
+ loose: true,
104
+ removeUniversalSelector: true
105
+ },
106
+ tailwindcss: {
107
+ config: 'path/to/your-tailwind.config.js',
108
+ cwd: 'project/cwd'
109
+ }
110
+ }
111
+ })
112
+ ```
113
+
79
114
  ## Migration form v1 to v2
80
115
 
81
116
  ### 0. cli command change
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",