-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtailwind.config.ts
72 lines (65 loc) · 2.91 KB
/
tailwind.config.ts
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
64
65
66
67
68
69
70
71
72
import { Config } from 'tailwindcss';
import plugin from 'tailwindcss/plugin';
import {
generateTailwindcssColorKeysPattern,
generateTailwindcssDimensionKeysPattern,
generateTailwindcssFontKeysPattern,
generateTailwindcssBorderKeysPattern,
} from '@uniformdev/theme-pack/tailwindcss-conf';
import theme from './tailwind.config.theme.json';
import utilities from './tailwind.utilities.json';
const safelist = [
{ pattern: /grid-cols-(1[0-2]|[1-9]|none|subgrid)/, variants: ['lg', 'md'] },
{ pattern: /gap(?:-(x|y))?-(0(\.5)?|1(\.5)?|2(\.5)?|3(\.5)?|[1-9]?[0-9]|px)/, variants: ['lg', 'md'] },
{ pattern: /flex-(col|row|col-reverse|row-reverse)/, variants: ['lg', 'md'] },
{ pattern: /justify-(normal|start|end|center|between|around|evenly|stretch)/, variants: ['lg', 'md'] },
{ pattern: /items-(start|end|center|baseline|stretch)/, variants: ['lg', 'md'] },
{ pattern: /self-(start|end|center|baseline|stretch)/, variants: ['lg', 'md'] },
{ pattern: /(col|row)-start-(1[0-2]|[1-9]|none|subgrid)/, variants: ['lg', 'md'] },
{ pattern: /(col|row)-(auto|span-(1[0-2]|[1-9]|full))/, variants: ['lg', 'md'] },
{ pattern: /justify-(start|center|end)/ },
{ pattern: /text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)/, variants: ['lg', 'md'] },
{ pattern: /text-(left|center|right)/ },
{ pattern: /font-(normal|medium|bold|extrabold)/, variants: ['lg', 'md'] },
{ pattern: /line-clamp-(none|[1-6])/, variants: ['lg:[&>:not(script)]', 'md:[&>:not(script)]', '[&>:not(script)]'] },
{ pattern: /(uppercase|lowercase|capitalize)/, variants: ['lg', 'md'] },
{ pattern: /(underline|overline|line-through)/, variants: ['lg', 'md'] },
{ pattern: /tracking-(tighter|tight|normal|wide|wider|widest)/, variants: ['lg', 'md'] },
{ pattern: /aspect-(auto|square|video)/ },
{ pattern: /shrink-(0|1)/ },
];
const colorKeys = Object.keys(theme.extend.colors || {});
if (colorKeys.length) {
safelist.push(generateTailwindcssColorKeysPattern(colorKeys));
}
const dimensionKeys = Object.keys(theme.extend.spacing || {});
if (dimensionKeys.length) {
safelist.push(...generateTailwindcssDimensionKeysPattern(dimensionKeys));
}
const fontKeys = Object.keys(theme.extend.fontFamily || {});
if (fontKeys.length) {
safelist.push(generateTailwindcssFontKeysPattern(fontKeys));
}
const borderKeys = Object.keys(utilities || {}).map(key => key.substring(1));
if (borderKeys.length) {
safelist.push(generateTailwindcssBorderKeysPattern(borderKeys));
}
const config: Config = {
darkMode: 'class',
content: [
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/hocs/**/*.{js,ts,jsx,tsx,mdx}',
'./src/stories/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
safelist,
theme,
plugins: [
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('@tailwindcss/typography'),
plugin(function ({ addUtilities }) {
addUtilities(utilities);
}),
],
};
export default config;