-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtailwind.config.cjs
44 lines (42 loc) · 1 KB
/
tailwind.config.cjs
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
const defaultTheme = require('tailwindcss/defaultTheme');
function rem2px(input, fontSize = 16) {
if (input == null) {
return input;
}
switch (typeof input) {
case 'object':
if (Array.isArray(input)) {
return input.map((val) => rem2px(val, fontSize));
}
const ret = {};
for (const key in input) {
ret[key] = rem2px(input[key], fontSize);
}
return ret;
case 'string':
return input.replace(
/(\d*\.?\d+)rem$/,
(_, val) => `${parseFloat(val) * fontSize}px`,
);
case 'function':
return eval(
input
.toString()
.replace(
/(\d*\.?\d+)rem/g,
(_, val) => `${parseFloat(val) * fontSize}px`,
),
);
default:
return input;
}
}
/** @type {import('tailwindcss').Config} */
module.exports = {
corePlugins: {
preflight: false,
},
content: ['./src/**/*.tsx'],
theme: rem2px(defaultTheme),
plugins: [require('@tailwindcss/typography')],
};