-
-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathpostcss.config.js
More file actions
63 lines (52 loc) · 1.8 KB
/
Copy pathpostcss.config.js
File metadata and controls
63 lines (52 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import tailwindcss from "@tailwindcss/postcss"
import autoprefixer from "autoprefixer"
import { contentRemIsolation } from "./plugins/content-rem-isolation.mjs"
const allApiHubRewriteTwProperties = () => ({
postcssPlugin: "all-api-hub-rewrite-tw-properties",
Once(root) {
const OLD_PREFIX = "--tw-"
const NEW_PREFIX = "--all-api-hub-tw-"
// 1) Rename @property --tw-* → --all-api-hub-tw-*
root.walkAtRules("property", (atRule) => {
if (
typeof atRule.params === "string" &&
atRule.params.includes(OLD_PREFIX)
) {
atRule.params = atRule.params.replaceAll(OLD_PREFIX, NEW_PREFIX)
}
})
// 2) Rename custom property declarations and usages
root.walkDecls((decl) => {
if (
decl.prop === "--tw-ring-shadow" ||
decl.prop === "--tw-ring-offset-shadow"
) {
// Older Chromium rejects an empty fallback for registered properties,
// even when --tw-ring-inset is set. A transparent zero-sized shadow
// keeps the outer ring valid; an explicit inset still takes precedence.
decl.value = decl.value.replace(
/var\(--tw-ring-inset,\s*\)/gu,
"var(--tw-ring-inset, 0 0 #0000,)",
)
}
if (decl.prop?.startsWith(OLD_PREFIX)) {
decl.prop = decl.prop.replace(OLD_PREFIX, NEW_PREFIX)
}
if (typeof decl.value === "string" && decl.value.includes(OLD_PREFIX)) {
decl.value = decl.value.replaceAll(OLD_PREFIX, NEW_PREFIX)
}
})
},
})
allApiHubRewriteTwProperties.postcss = true
export default {
plugins: [
// Tailwind v4 core
tailwindcss(),
// Rewrite Tailwind internal CSS variables to an extension-specific prefix
allApiHubRewriteTwProperties(),
contentRemIsolation(),
// Vendor prefixes last
autoprefixer(),
],
}