The project uses unocss with unocss-applet extensions to manage styling. The configuration defines custom shortcuts for base colors and borders, integrates icon presets, and uses specific transformers to handle directives and applet-specific syntax.
Key configuration areas include:
- Shortcuts: Predefined utility classes like
bg-base, color-base, and bg-primary that combine multiple utility classes. - Presets: Includes
presetIcons (with custom scale and alignment), presetApplet (conditional based on platform), presetAttributify, and presetRemToRpx. - Transformers: Uses
transformerDirectives, transformerVariantGroup, transformerAttributify, and transformerApplet. Note that the order of transformerAttributify and transformerApplet is significant. - Rules: Custom utility rules for handling safe area insets (e.g.,
p-safe, pt-safe, pb-safe). - Safelist: Ensures dynamic color classes for course scheduling (e.g.,
bg-rose, text-pink-5) are not purged by the CSS engine.
import { defineConfig, presetIcons, presetAttributify } from 'unocss'
import { presetApplet, presetRemToRpx, transformerApplet, transformerAttributify } from 'unocss-applet'
export default defineConfig({
shortcuts: {
'bg-base': 'bg-gray-100 dark:bg-dark',
'bg-primary': 'bg-light-blue-500 dark:bg-light-blue-600/80',
// ...
},
presets: [
presetIcons({ scale: 1.2, extraProperties: { 'display': 'inline-block', 'vertical-align': 'middle' } }),
presetApplet({ enable: !isH5 }),
presetAttributify(),
presetRemToRpx({ enable: !isH5 }),
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
transformerAttributify(),
transformerApplet(),
],
rules: [
['p-safe', { padding: 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)' }],
],
safelist: [
// Dynamically generated color classes
]
})