@weapp-tailwindcss/merge 2.2.1 → 2.2.3
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 +23 -87
- package/README.zh-CN.md +36 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +2 -1
- package/dist/lite.cjs +2 -1
- package/dist/lite.d.cts +0 -1
- package/dist/lite.d.mts +0 -1
- package/dist/lite.mjs +2 -1
- package/dist/slim.cjs +3 -1
- package/dist/slim.d.cts +0 -1
- package/dist/slim.d.mts +0 -1
- package/dist/slim.mjs +3 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,100 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
# @weapp-tailwindcss/merge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> English | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
</a>
|
|
5
|
+
A cross-platform wrapper around Tailwind Merge v3. It resolves conflicting utilities while keeping arbitrary values, `rpx`, and mini-program-safe class escaping consistent with `weapp-tailwindcss`.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Installation
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @weapp-tailwindcss/merge
|
|
11
|
+
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
## Usage
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
```ts
|
|
16
|
+
import { twMerge } from '@weapp-tailwindcss/merge'
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
|
|
18
|
+
const className = twMerge(
|
|
19
|
+
'rounded px-2 text-[28rpx]',
|
|
20
|
+
'px-4 text-surface-700',
|
|
21
|
+
)
|
|
22
|
+
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
> 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
|
|
25
|
-
>
|
|
26
|
-
> `weapp-tailwindcss@4.2.x` 现已支持 `uni-app x` 同时构建 `Web`,`小程序`,`安卓`,`IOS`,`鸿蒙`,详见 [**uni-app x 专题**](https://tw.icebreaker.top/docs/uni-app-x)
|
|
24
|
+
The default runtime returns escaped classes suitable for mini-program templates. Create an unescaped runtime when another target owns class serialization:
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
```ts
|
|
27
|
+
import { create } from '@weapp-tailwindcss/merge'
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- [安装与使用方式](#安装与使用方式)
|
|
33
|
-
- [生态和解决方案](#生态和解决方案)
|
|
34
|
-
- [常见问题](#常见问题)
|
|
35
|
-
- [各个框架的模板](#各个框架的模板)
|
|
36
|
-
- [旧版本迁移指南](#旧版本迁移指南)
|
|
37
|
-
- [配置项参考](#配置项参考)
|
|
38
|
-
- [Contribute](#contribute)
|
|
39
|
-
- [License](#license)
|
|
40
|
-
- [Star History](#star-history)
|
|
41
|
-
- [Related projects](#related-projects)
|
|
42
|
-
- [weapp-vite](#weapp-vite)
|
|
29
|
+
const { twMerge } = create({ escape: false })
|
|
30
|
+
```
|
|
43
31
|
|
|
44
|
-
|
|
32
|
+
Use the `slim` entry for a smaller preconfigured class-group set or `lite` when you only need joining and escaping without conflict resolution.
|
|
45
33
|
|
|
46
|
-
|
|
47
|
-
| --------------------------------------------------- | ----------------------------------------------- |
|
|
48
|
-
|  |  |
|
|
34
|
+
## Documentation
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
也支持直接从各个开发者工具中,直接创建的原生小程序应用。
|
|
53
|
-
|
|
54
|
-
这些插件能够自动识别并精确处理所有 `tailwindcss` 的工具类来适配小程序环境。
|
|
55
|
-
|
|
56
|
-
## 版本对应
|
|
57
|
-
|
|
58
|
-
目前,`weapp-tailwindcss` 的 `4.x` 版本
|
|
59
|
-
|
|
60
|
-
- 支持最新版本的 `tailwindcss v4` 和 `v3` 还有 `v2 jit` 版本。
|
|
61
|
-
- 支持 `webpack5`,`webpack4`, `vite` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
|
|
62
|
-
|
|
63
|
-
> 如果你还在使用 `tailwindcss@2` 版本,那你应该使用从 `weapp-tailwindcss/webpack4` 导出的本插件的 `postcss7` `webpack4` 版本。另外请确保你的 `nodejs` 版本 `>=16.6.0`。目前低于 `16` 的长期维护版本(`偶数版本`) 都已经结束了生命周期,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
|
|
64
|
-
|
|
65
|
-
## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
|
|
66
|
-
|
|
67
|
-
## [生态和解决方案](https://tw.icebreaker.top/docs/community/templates)
|
|
68
|
-
|
|
69
|
-
## [常见问题](https://tw.icebreaker.top/docs/issues/)
|
|
70
|
-
|
|
71
|
-
## [各个框架的模板](https://tw.icebreaker.top/docs/community/templates)
|
|
72
|
-
|
|
73
|
-
## [旧版本迁移指南](https://tw.icebreaker.top/docs/migrations/v2)
|
|
74
|
-
|
|
75
|
-
## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
|
|
76
|
-
|
|
77
|
-
## Contribute
|
|
78
|
-
|
|
79
|
-
我们邀请你来贡献和帮助改进 `weapp-tailwindcss` 💚💚💚
|
|
80
|
-
|
|
81
|
-
以下有几个方式可以参与:
|
|
82
|
-
|
|
83
|
-
- 报告错误:如果您遇到任何错误或问题,请提`issue`并提供完善的错误信息和复现方式。
|
|
84
|
-
- 建议:有增强 `weapp-tailwindcss` 的想法吗?请提 `issue` 来分享您的建议。
|
|
85
|
-
- 文档:如果您对文档有更好的见解或者更棒的修辞方式,欢迎 `pr`。
|
|
86
|
-
- 代码:任何人的代码都不是完美的,我们欢迎你通过 `pr` 给代码提供更好的质量与活力。
|
|
87
|
-
|
|
88
|
-
## License
|
|
89
|
-
|
|
90
|
-
[MIT](./LICENSE)
|
|
91
|
-
|
|
92
|
-
## Star History
|
|
93
|
-
|
|
94
|
-
[](https://star-history.com/#sonofmagic/weapp-tailwindcss&Date)
|
|
95
|
-
|
|
96
|
-
## Related projects
|
|
97
|
-
|
|
98
|
-
### weapp-vite
|
|
99
|
-
|
|
100
|
-
[weapp-vite](https://vite.icebreaker.top/): 把现代化的开发模式带入小程序开发!
|
|
36
|
+
See the [merge guide](https://tw.weapp.dev/docs/community/merge/overview) for configuration and migration details.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @weapp-tailwindcss/merge
|
|
2
|
+
|
|
3
|
+
> [English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
Tailwind Merge v3 的跨端运行时封装。它在合并冲突 utility 的同时,让任意值、`rpx` 与小程序安全 class 转义保持和 `weapp-tailwindcss` 一致。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @weapp-tailwindcss/merge
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { twMerge } from '@weapp-tailwindcss/merge'
|
|
17
|
+
|
|
18
|
+
const className = twMerge(
|
|
19
|
+
'rounded px-2 text-[28rpx]',
|
|
20
|
+
'px-4 text-surface-700',
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
默认运行时返回可直接用于小程序模板的安全 class。其他目标端自行负责 class 序列化时,可以创建不转义的运行时:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { create } from '@weapp-tailwindcss/merge'
|
|
28
|
+
|
|
29
|
+
const { twMerge } = create({ escape: false })
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
需要更小的预配置 class group 时使用 `slim` 入口;只需要拼接与转义、不需要冲突合并时使用 `lite` 入口。
|
|
33
|
+
|
|
34
|
+
## 文档
|
|
35
|
+
|
|
36
|
+
配置与迁移说明见 [merge 指南](https://tw.weapp.dev/zh-cn/docs/community/merge/overview)。
|
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let _weapp_tailwindcss_runtime = require("@weapp-tailwindcss/runtime");
|
|
3
3
|
let tailwind_merge = require("tailwind-merge");
|
|
4
4
|
//#region src/index.ts
|
|
5
|
+
const rpxTransform = (0, _weapp_tailwindcss_runtime.createRpxLengthTransform)();
|
|
5
6
|
const create = (0, _weapp_tailwindcss_runtime.createRuntimeFactory)({
|
|
6
7
|
createTailwindMerge: tailwind_merge.createTailwindMerge,
|
|
7
8
|
extendTailwindMerge: tailwind_merge.extendTailwindMerge,
|
|
8
9
|
twJoin: tailwind_merge.twJoin,
|
|
9
10
|
twMerge: tailwind_merge.twMerge,
|
|
10
11
|
version: 3,
|
|
11
|
-
...
|
|
12
|
+
...rpxTransform
|
|
12
13
|
});
|
|
13
14
|
const { version: tailwindMergeVersion, twMerge, twJoin, extendTailwindMerge, createTailwindMerge } = create();
|
|
14
15
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { getDefaultConfig, mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/index.d.ts
|
|
5
4
|
declare const create: (createOptions?: import("@weapp-tailwindcss/runtime").CreateOptions) => {
|
|
6
5
|
version: import("@weapp-tailwindcss/runtime").TailwindMergeVersion;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { getDefaultConfig, mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/index.d.ts
|
|
5
4
|
declare const create: (createOptions?: import("@weapp-tailwindcss/runtime").CreateOptions) => {
|
|
6
5
|
version: import("@weapp-tailwindcss/runtime").TailwindMergeVersion;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createRpxLengthTransform, createRuntimeFactory, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1, extendTailwindMerge as extendTailwindMerge$1, getDefaultConfig, mergeConfigs, twJoin as twJoin$1, twMerge as twMerge$1 } from "tailwind-merge";
|
|
3
3
|
//#region src/index.ts
|
|
4
|
+
const rpxTransform = createRpxLengthTransform();
|
|
4
5
|
const create = createRuntimeFactory({
|
|
5
6
|
createTailwindMerge: createTailwindMerge$1,
|
|
6
7
|
extendTailwindMerge: extendTailwindMerge$1,
|
|
7
8
|
twJoin: twJoin$1,
|
|
8
9
|
twMerge: twMerge$1,
|
|
9
10
|
version: 3,
|
|
10
|
-
...
|
|
11
|
+
...rpxTransform
|
|
11
12
|
});
|
|
12
13
|
const { version: tailwindMergeVersion, twMerge, twJoin, extendTailwindMerge, createTailwindMerge } = create();
|
|
13
14
|
//#endregion
|
package/dist/lite.cjs
CHANGED
|
@@ -2,13 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let _weapp_tailwindcss_runtime = require("@weapp-tailwindcss/runtime");
|
|
3
3
|
let tailwind_merge = require("tailwind-merge");
|
|
4
4
|
//#region src/lite.ts
|
|
5
|
+
const rpxTransform = (0, _weapp_tailwindcss_runtime.createRpxLengthTransform)();
|
|
5
6
|
const create = (0, _weapp_tailwindcss_runtime.createRuntimeFactory)({
|
|
6
7
|
createTailwindMerge: tailwind_merge.createTailwindMerge,
|
|
7
8
|
extendTailwindMerge: tailwind_merge.createTailwindMerge,
|
|
8
9
|
twJoin: tailwind_merge.twJoin,
|
|
9
10
|
twMerge: tailwind_merge.twJoin,
|
|
10
11
|
version: 3,
|
|
11
|
-
...
|
|
12
|
+
...rpxTransform
|
|
12
13
|
});
|
|
13
14
|
const { version: tailwindMergeVersion, twJoin, extendTailwindMerge: _wrappedExtendTailwindMerge, createTailwindMerge } = create();
|
|
14
15
|
//#endregion
|
package/dist/lite.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/lite.d.ts
|
|
5
4
|
declare const create: (createOptions?: import("@weapp-tailwindcss/runtime").CreateOptions) => {
|
|
6
5
|
version: import("@weapp-tailwindcss/runtime").TailwindMergeVersion;
|
package/dist/lite.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/lite.d.ts
|
|
5
4
|
declare const create: (createOptions?: import("@weapp-tailwindcss/runtime").CreateOptions) => {
|
|
6
5
|
version: import("@weapp-tailwindcss/runtime").TailwindMergeVersion;
|
package/dist/lite.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createRpxLengthTransform, createRuntimeFactory, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1, mergeConfigs, twJoin as twJoin$1 } from "tailwind-merge";
|
|
3
3
|
//#region src/lite.ts
|
|
4
|
+
const rpxTransform = createRpxLengthTransform();
|
|
4
5
|
const create = createRuntimeFactory({
|
|
5
6
|
createTailwindMerge: createTailwindMerge$1,
|
|
6
7
|
extendTailwindMerge: createTailwindMerge$1,
|
|
7
8
|
twJoin: twJoin$1,
|
|
8
9
|
twMerge: twJoin$1,
|
|
9
10
|
version: 3,
|
|
10
|
-
...
|
|
11
|
+
...rpxTransform
|
|
11
12
|
});
|
|
12
13
|
const { version: tailwindMergeVersion, twJoin, extendTailwindMerge: _wrappedExtendTailwindMerge, createTailwindMerge } = create();
|
|
13
14
|
//#endregion
|
package/dist/slim.cjs
CHANGED
|
@@ -1533,11 +1533,13 @@ const rpxTransform = (0, _weapp_tailwindcss_runtime.createRpxLengthTransform)();
|
|
|
1533
1533
|
function _extendTailwindMerge(configExtension, ...createConfig) {
|
|
1534
1534
|
return typeof configExtension === "function" ? (0, tailwind_merge.createTailwindMerge)(getSlimConfig, configExtension, ...createConfig) : (0, tailwind_merge.createTailwindMerge)(() => (0, tailwind_merge.mergeConfigs)(getSlimConfig(), configExtension), ...createConfig);
|
|
1535
1535
|
}
|
|
1536
|
+
/** 基于 Slim_Config 的预配置 twMerge */
|
|
1537
|
+
const _twMerge = (0, tailwind_merge.createTailwindMerge)(getSlimConfig);
|
|
1536
1538
|
const create = (0, _weapp_tailwindcss_runtime.createRuntimeFactory)({
|
|
1537
1539
|
createTailwindMerge: tailwind_merge.createTailwindMerge,
|
|
1538
1540
|
extendTailwindMerge: _extendTailwindMerge,
|
|
1539
1541
|
twJoin: tailwind_merge.twJoin,
|
|
1540
|
-
twMerge:
|
|
1542
|
+
twMerge: _twMerge,
|
|
1541
1543
|
version: 3,
|
|
1542
1544
|
...rpxTransform
|
|
1543
1545
|
});
|
package/dist/slim.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { Config, mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/slim-config.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* 精简版 tailwind-merge 配置,仅包含小程序场景中高频使用的 Tailwind 类冲突分组。
|
package/dist/slim.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, CreateOptions, EscapeConfig, UnescapeConfig, weappTwIgnore } from "@weapp-tailwindcss/runtime";
|
|
2
2
|
import { Config, mergeConfigs } from "tailwind-merge";
|
|
3
|
-
|
|
4
3
|
//#region src/slim-config.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* 精简版 tailwind-merge 配置,仅包含小程序场景中高频使用的 Tailwind 类冲突分组。
|
package/dist/slim.mjs
CHANGED
|
@@ -1532,11 +1532,13 @@ const rpxTransform = createRpxLengthTransform();
|
|
|
1532
1532
|
function _extendTailwindMerge(configExtension, ...createConfig) {
|
|
1533
1533
|
return typeof configExtension === "function" ? createTailwindMerge$1(getSlimConfig, configExtension, ...createConfig) : createTailwindMerge$1(() => mergeConfigs(getSlimConfig(), configExtension), ...createConfig);
|
|
1534
1534
|
}
|
|
1535
|
+
/** 基于 Slim_Config 的预配置 twMerge */
|
|
1536
|
+
const _twMerge = createTailwindMerge$1(getSlimConfig);
|
|
1535
1537
|
const create = createRuntimeFactory({
|
|
1536
1538
|
createTailwindMerge: createTailwindMerge$1,
|
|
1537
1539
|
extendTailwindMerge: _extendTailwindMerge,
|
|
1538
1540
|
twJoin: twJoin$1,
|
|
1539
|
-
twMerge:
|
|
1541
|
+
twMerge: _twMerge,
|
|
1540
1542
|
version: 3,
|
|
1541
1543
|
...rpxTransform
|
|
1542
1544
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/merge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
5
|
-
"description": "Tailwind
|
|
4
|
+
"version": "2.2.3",
|
|
5
|
+
"description": "Cross-platform Tailwind CSS class merging runtime with mini-program compatibility. 兼容小程序的跨端 Tailwind CSS 类名合并运行时。",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://tw.
|
|
8
|
+
"homepage": "https://tw.weapp.dev/docs/community/merge/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@weapp-core/escape": "^8.0.0",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
76
|
+
"@weapp-tailwindcss/runtime": "0.1.8",
|
|
77
|
+
"tailwind-merge": "^3.6.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"fast-check": "^4.
|
|
80
|
+
"fast-check": "^4.9.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"dev": "tsdown --watch --sourcemap",
|