gitech
/
tailwind.config.js
101 строка · 3.1 Кб
1import {readFileSync} from 'node:fs';2import {env} from 'node:process';3import {parse} from 'postcss';4
5const isProduction = env.NODE_ENV !== 'development';6
7function extractRootVars(css) {8const root = parse(css);9const vars = new Set();10root.walkRules((rule) => {11if (rule.selector !== ':root') return;12rule.each((decl) => {13if (decl.value && decl.prop.startsWith('--')) {14vars.add(decl.prop.substring(2));15}16});17});18return Array.from(vars);19}
20
21const vars = extractRootVars([22readFileSync(new URL('web_src/css/themes/theme-gitea-light.css', import.meta.url), 'utf8'),23readFileSync(new URL('web_src/css/themes/theme-gitea-dark.css', import.meta.url), 'utf8'),24].join('\n'));25
26export default {27prefix: 'tw-',28important: true, // the frameworks are mixed together, so tailwind needs to override other framework's styles29content: [30isProduction && '!./templates/devtest/**/*',31isProduction && '!./web_src/js/standalone/devtest.js',32'!./templates/swagger/v1_json.tmpl',33'!./templates/user/auth/oidc_wellknown.tmpl',34'!**/*_test.go',35'!./modules/{public,options,templates}/bindata.go',36'./{build,models,modules,routers,services}/**/*.go',37'./templates/**/*.tmpl',38'./web_src/js/**/*.{js,vue}',39].filter(Boolean),40blocklist: [41// classes that don't work without CSS variables from "@tailwind base" which we don't use42'transform', 'shadow', 'ring', 'blur', 'grayscale', 'invert', '!invert', 'filter', '!filter',43'backdrop-filter',44// we use double-class tw-hidden defined in web_src/css/helpers.css for increased specificity45'hidden',46// unneeded classes47'[-a-zA-Z:0-9_.]',48],49theme: {50colors: {51// make `tw-bg-red` etc work with our CSS variables52...Object.fromEntries(vars.filter((prop) => prop.startsWith('color-')).map((prop) => {53const color = prop.substring(6);54return [color, `var(--color-${color})`];55})),56inherit: 'inherit',57current: 'currentcolor',58transparent: 'transparent',59},60borderRadius: {61'none': '0',62'sm': '2px',63'DEFAULT': 'var(--border-radius)', // 4px64'md': 'var(--border-radius-medium)', // 6px65'lg': '8px',66'xl': '12px',67'2xl': '16px',68'3xl': '24px',69'full': 'var(--border-radius-circle)', // 50%70},71fontFamily: {72sans: 'var(--fonts-regular)',73mono: 'var(--fonts-monospace)',74},75fontWeight: {76light: 'var(--font-weight-light)',77normal: 'var(--font-weight-normal)',78medium: 'var(--font-weight-medium)',79semibold: 'var(--font-weight-semibold)',80bold: 'var(--font-weight-bold)',81},82fontSize: { // not using `rem` units because our root is currently 14px83'xs': '12px',84'sm': '14px',85'base': '16px',86'lg': '18px',87'xl': '20px',88'2xl': '24px',89'3xl': '30px',90'4xl': '36px',91'5xl': '48px',92'6xl': '60px',93'7xl': '72px',94'8xl': '96px',95'9xl': '128px',96...Object.fromEntries(Array.from({length: 100}, (_, i) => {97return [`${i}`, `${i === 0 ? '0' : `${i}px`}`];98})),99},100},101};102