You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tailwind.config.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {readFileSync} from 'node:fs';
  2. import {env} from 'node:process';
  3. import {parse} from 'postcss';
  4. const isProduction = env.NODE_ENV !== 'development';
  5. function extractRootVars(css) {
  6. const root = parse(css);
  7. const vars = new Set();
  8. root.walkRules((rule) => {
  9. if (rule.selector !== ':root') return;
  10. rule.each((decl) => {
  11. if (decl.value && decl.prop.startsWith('--')) {
  12. vars.add(decl.prop.substring(2));
  13. }
  14. });
  15. });
  16. return Array.from(vars);
  17. }
  18. const vars = extractRootVars([
  19. readFileSync(new URL('web_src/css/themes/theme-gitea-light.css', import.meta.url), 'utf8'),
  20. readFileSync(new URL('web_src/css/themes/theme-gitea-dark.css', import.meta.url), 'utf8'),
  21. ].join('\n'));
  22. export default {
  23. prefix: 'tw-',
  24. important: true, // the frameworks are mixed together, so tailwind needs to override other framework's styles
  25. content: [
  26. isProduction && '!./templates/devtest/**/*',
  27. isProduction && '!./web_src/js/standalone/devtest.js',
  28. '!./templates/swagger/v1_json.tmpl',
  29. '!./templates/user/auth/oidc_wellknown.tmpl',
  30. '!**/*_test.go',
  31. '!./modules/{public,options,templates}/bindata.go',
  32. './{build,models,modules,routers,services}/**/*.go',
  33. './templates/**/*.tmpl',
  34. './web_src/js/**/*.{js,vue}',
  35. ].filter(Boolean),
  36. blocklist: [
  37. // classes that don't work without CSS variables from "@tailwind base" which we don't use
  38. 'transform', 'shadow', 'ring', 'blur', 'grayscale', 'invert', '!invert', 'filter', '!filter',
  39. 'backdrop-filter',
  40. // unneeded classes
  41. '[-a-zA-Z:0-9_.]',
  42. ],
  43. theme: {
  44. colors: {
  45. // make `tw-bg-red` etc work with our CSS variables
  46. ...Object.fromEntries(vars.filter((prop) => prop.startsWith('color-')).map((prop) => {
  47. const color = prop.substring(6);
  48. return [color, `var(--color-${color})`];
  49. })),
  50. inherit: 'inherit',
  51. current: 'currentcolor',
  52. transparent: 'transparent',
  53. },
  54. },
  55. };