tailwind.config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /** @type {import('tailwindcss').Config} */
  2. function genSimilarColorsName(brandName) {
  3. return {
  4. lighter: `var(--${brandName}-lighter-color)`,
  5. light: `var(--${brandName}-light-color)`,
  6. DEFAULT: `var(--${brandName}-color)`,
  7. deep: `var(--${brandName}-deep-color)`,
  8. deeper: `var(--${brandName}-deeper-color)`
  9. };
  10. }
  11. function genSimpleColorsName(names) {
  12. const colors = {};
  13. names.forEach(name => {
  14. colors[name] = `var(--${name}-color)`
  15. });
  16. return colors
  17. }
  18. module.exports = {
  19. separator: '__', // 如果是小程序项目需要设置这一项,将 : 选择器替换成 __,之后 hover:bg-red-500 将改为 hover__bg-red-500
  20. corePlugins: {
  21. // 预设样式
  22. preflight: false, // 一般uniapp都有预设样式,所以不需要tailwindcss的预设
  23. // 以下功能小程序不支持
  24. space: false, // > 子节点选择器
  25. divideWidth: false,
  26. divideColor: false,
  27. divideStyle: false,
  28. divideOpacity: false,
  29. },
  30. content: [
  31. './pages/**/*.{vue,js,ts,jsx,tsx}',
  32. './components/**/*.{vue,js,ts,jsx,tsx}',
  33. './main.js',
  34. './App.vue',
  35. './index.html'
  36. ],
  37. safelist: [
  38. {pattern: /grid-cols-[1-9]/}
  39. ],
  40. theme: {
  41. spacing(config) {
  42. let result = {0: '0', 'px': '0.5px'}
  43. // 允许的数值大一些也无所谓,最后打包tailwindcss会摇树优化,未使用的样式并不会打包
  44. for (let i = 1; i <= 300; i++) {
  45. result[i] = `${i}rpx`
  46. }
  47. return result
  48. },
  49. fontSize: {
  50. "base": '15px',
  51. "sm": '14px',
  52. "xs": '13px',
  53. "2xs": '12px',
  54. "3xs": '11px',
  55. "4xs": '10px',
  56. "lg": '16px',
  57. 'xl': '18px',
  58. '2xl': '20px',
  59. '3xl': '24px',
  60. '4xl': '28px',
  61. '5xl': '32px',
  62. '6xl': '36px',
  63. '7xl': '40px'
  64. },
  65. extend: {
  66. colors: {
  67. primary: genSimilarColorsName('primary'),
  68. success: genSimilarColorsName('success'),
  69. warning: genSimilarColorsName('warning'),
  70. error: genSimilarColorsName('error'),
  71. info: genSimilarColorsName('info'),
  72. ...genSimpleColorsName(['main', 'content', 'tips', 'light', 'border', 'bg', 'disabled'])
  73. },
  74. borderWidth: {
  75. DEFAULT: '0.5px',
  76. 1: '1px'
  77. },
  78. backgroundImage: {
  79. 'register-bright': "url('/static/personal/top_bg.png')"
  80. },
  81. boxShadow: {
  82. 'up': '0 -1px 3px 0 rgb(0 0 0 / 0.1), 0 -1px 2px -1px rgb(0 0 0 / 0.1)'
  83. },
  84. flex: {
  85. 2: '2',
  86. 3: '3',
  87. 4: '4',
  88. 5: '5',
  89. 6: '6',
  90. 7: '7',
  91. 8: '8',
  92. 9: '9',
  93. 10: '10'
  94. }
  95. },
  96. },
  97. plugins: [],
  98. }