tailwindcss-patch 2.0.5 → 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.
- package/README.md +48 -13
- package/dist/cli.cjs +46 -0
- package/dist/cli.mjs +20 -13
- package/dist/{chunk-PZNRLYGX.mjs → index.cjs} +180 -253
- package/dist/index.mjs +522 -63
- package/package.json +4 -20
- package/dist/cli.d.mts +0 -2
- package/dist/cli.js +0 -643
- package/dist/index.d.mts +0 -149
- package/dist/index.js +0 -661
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
|
-
|
|
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
|
|
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
|
-
|
|
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/dist/cli.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const cac = require('cac');
|
|
4
|
+
const index = require('./index.cjs');
|
|
5
|
+
require('node:path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:fs/promises');
|
|
8
|
+
require('resolve');
|
|
9
|
+
require('@babel/types');
|
|
10
|
+
require('@babel/generator');
|
|
11
|
+
require('@babel/traverse');
|
|
12
|
+
require('@babel/parser');
|
|
13
|
+
const config = require('@tailwindcss-mangle/config');
|
|
14
|
+
require('semver');
|
|
15
|
+
require('postcss');
|
|
16
|
+
require('lilconfig');
|
|
17
|
+
require('jiti');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
20
|
+
|
|
21
|
+
const cac__default = /*#__PURE__*/_interopDefaultCompat(cac);
|
|
22
|
+
|
|
23
|
+
function init() {
|
|
24
|
+
const cwd = process.cwd();
|
|
25
|
+
return config.initConfig(cwd);
|
|
26
|
+
}
|
|
27
|
+
const cli = cac__default();
|
|
28
|
+
cli.command("install", "patch install").action(() => {
|
|
29
|
+
const opt = index.getPatchOptions();
|
|
30
|
+
const patch = index.createPatch(opt);
|
|
31
|
+
patch();
|
|
32
|
+
});
|
|
33
|
+
cli.command("init").action(async () => {
|
|
34
|
+
await init();
|
|
35
|
+
console.log(`\u2728 ${config.configName}.config.ts initialized!`);
|
|
36
|
+
});
|
|
37
|
+
cli.command("extract").action(async () => {
|
|
38
|
+
const { config: config$1 } = await config.getConfig();
|
|
39
|
+
if (config$1) {
|
|
40
|
+
const twPatcher = new index.TailwindcssPatcher();
|
|
41
|
+
const p = await twPatcher.extract(config$1.patch);
|
|
42
|
+
console.log("\u2728 tailwindcss-patch extract success! file path: " + p);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
cli.help();
|
|
46
|
+
cli.parse();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import cac from 'cac';
|
|
2
|
+
import { getPatchOptions, TailwindcssPatcher, createPatch } from './index.mjs';
|
|
3
|
+
import 'node:path';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import 'node:fs/promises';
|
|
6
|
+
import 'resolve';
|
|
7
|
+
import '@babel/types';
|
|
8
|
+
import '@babel/generator';
|
|
9
|
+
import '@babel/traverse';
|
|
10
|
+
import '@babel/parser';
|
|
11
|
+
import { configName, getConfig, initConfig } from '@tailwindcss-mangle/config';
|
|
12
|
+
import 'semver';
|
|
13
|
+
import 'postcss';
|
|
14
|
+
import 'lilconfig';
|
|
15
|
+
import 'jiti';
|
|
7
16
|
|
|
8
|
-
// src/cli.ts
|
|
9
|
-
import cac from "cac";
|
|
10
17
|
function init() {
|
|
11
18
|
const cwd = process.cwd();
|
|
12
|
-
return
|
|
19
|
+
return initConfig(cwd);
|
|
13
20
|
}
|
|
14
|
-
|
|
21
|
+
const cli = cac();
|
|
15
22
|
cli.command("install", "patch install").action(() => {
|
|
16
23
|
const opt = getPatchOptions();
|
|
17
24
|
const patch = createPatch(opt);
|
|
@@ -19,14 +26,14 @@ cli.command("install", "patch install").action(() => {
|
|
|
19
26
|
});
|
|
20
27
|
cli.command("init").action(async () => {
|
|
21
28
|
await init();
|
|
22
|
-
console.log(`\u2728 ${
|
|
29
|
+
console.log(`\u2728 ${configName}.config.ts initialized!`);
|
|
23
30
|
});
|
|
24
31
|
cli.command("extract").action(async () => {
|
|
25
|
-
const { config } = await
|
|
32
|
+
const { config } = await getConfig();
|
|
26
33
|
if (config) {
|
|
27
34
|
const twPatcher = new TailwindcssPatcher();
|
|
28
35
|
const p = await twPatcher.extract(config.patch);
|
|
29
|
-
console.log("\u2728 tailwindcss-patch extract success! file path
|
|
36
|
+
console.log("\u2728 tailwindcss-patch extract success! file path: " + p);
|
|
30
37
|
}
|
|
31
38
|
});
|
|
32
39
|
cli.help();
|