Skip to content

Config File

IDE 및 기타 통합에서 최상의 경험을 얻기 위해 UnoCSS를 구성할 때 전용 uno.config.ts 파일을 사용하는 것을 강력히 권장합니다.

완전한 기능을 갖춘 설정 파일은 다음과 같습니다:

ts
import {
  defineConfig,
  presetAttributify,
  presetIcons,
  presetTypography,
  presetWebFonts,
  presetWind3,
  transformerDirectives,
  transformerVariantGroup
} from 'unocss'

export default defineConfig({
  shortcuts: [
    // ...
  ],
  theme: {
    colors: {
      // ...
    }
  },
  presets: [
    presetWind3(),
    presetAttributify(),
    presetIcons(),
    presetTypography(),
    presetWebFonts({
      fonts: {
        // ...
      },
    }),
  ],
  transformers: [
    transformerDirectives(),
    transformerVariantGroup(),
  ],
})

vite.config.ts 또는 기타 도구 설정 내의 인라인 구성과 비교하여, 전용 설정 파일은 IDE 및 통합, ESLint 플러그인과 같은 기타 도구와 더 잘 작동하며, HMR도 더 잘 작동합니다.

기본적으로 UnoCSS는 프로젝트 루트 디렉토리에서 uno.config.{js,ts,mjs,mts} 또는 unocss.config.{js,ts,mjs,mts}를 자동으로 찾습니다. 설정 파일을 수동으로 지정할 수도 있습니다. 예를 들어 Vite에서:

ts
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    UnoCSS({
      configFile: '../my-uno.config.ts',
    }),
  ],
})

지원되는 구성 옵션의 전체 목록은 Configurations reference를 참조하세요.

Released under the MIT License.