-
Notifications
You must be signed in to change notification settings - Fork 2
/
postcss.config.js
35 lines (32 loc) · 1.03 KB
/
postcss.config.js
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
import postcssRemToPx from '@thedutchcoder/postcss-rem-to-px'
import autoprefixer from 'autoprefixer'
import postcssPrefixSelector from 'postcss-prefix-selector'
import tailwindcss from 'tailwindcss'
/**
* Transforms a CSS selector based on a given prefix.
* @param {string} prefix - The prefix to apply to the selector.
* @param {string} selector - The original CSS selector.
* @param {string} prefixedSelector - The CSS selector with the prefix applied.
* @returns {string} The transformed CSS selector.
*/
function transformSelector(prefix, selector, prefixedSelector) {
if ([':root', ':host', 'html', 'body'].includes(selector)) {
return ':host'
}
if (['[data-theme]', '[data-theme=light]', '[data-theme=dark]'].includes(selector)) {
return `:host ${selector}`
}
return prefixedSelector
}
const postcssConfig = {
plugins: [
tailwindcss(),
postcssPrefixSelector({
prefix: '#gt-app',
transform: transformSelector,
}),
postcssRemToPx(),
autoprefixer(),
],
}
export default postcssConfig