This commit is contained in:
icssoa 2025-06-23 18:21:09 +08:00
parent 73c8a53654
commit e645760760
2 changed files with 26 additions and 2 deletions

View File

@ -1750,6 +1750,7 @@ if (typeof window !== 'undefined') {
},
// 处理声明规则
Declaration(decl) {
const className = decl.parent.selector || "";
// 处理 Tailwind 自定义属性
if (decl.prop.includes("--tw-")) {
colorValues[decl.prop] = decl.value.includes("rem")
@ -1766,7 +1767,7 @@ if (typeof window !== 'undefined') {
// 处理文本大小相关样式
if (decl.value.includes("rpx") &&
decl.prop == "color" &&
decl.parent.selector?.includes("text-")) {
className.includes("text-")) {
decl.prop = "font-size";
}
// 删除不支持的属性
@ -1780,6 +1781,17 @@ if (typeof window !== 'undefined') {
decl.value = "1";
}
}
// 处理 visibility 属性
if (decl.prop == "visibility") {
decl.remove();
}
// 处理 sticky 属性
if (className == ".sticky") {
if (decl.prop == "position" ||
decl.value == "sticky") {
decl.remove();
}
}
// 解析声明值
const parsed = valueParser(decl.value);
let hasChanges = false;

View File

@ -134,6 +134,8 @@ function postcssPlugin(): Plugin {
// 处理声明规则
Declaration(decl: any) {
const className = decl.parent.selector || "";
// 处理 Tailwind 自定义属性
if (decl.prop.includes("--tw-")) {
colorValues[decl.prop] = decl.value.includes("rem")
@ -155,7 +157,7 @@ function postcssPlugin(): Plugin {
if (
decl.value.includes("rpx") &&
decl.prop == "color" &&
decl.parent.selector?.includes("text-")
className.includes("text-")
) {
decl.prop = "font-size";
}
@ -178,6 +180,16 @@ function postcssPlugin(): Plugin {
decl.remove();
}
// 处理 sticky 属性
if (className == ".sticky") {
if (
decl.prop == "position" ||
decl.value == "sticky"
) {
decl.remove();
}
}
// 解析声明值
const parsed = valueParser(decl.value);
let hasChanges = false;