Skip to content

ट्रांसफॉर्मर्स

कन्वेंशन का समर्थन करने के लिए स्रोत कोड को रूपांतरित करने के लिए एक एकीकृत इंटरफ़ेस प्रदान करता है।

ts
import { SourceCodeTransformer } from 'unocss'
import { createFilter } from 'unplugin-utils'

export default function myTransformers(options: MyOptions = {}): SourceCodeTransformer {
  return {
    name: 'my-transformer',
    enforce: 'pre', // enforce before other transformers
    idFilter(id) {
      // only transform .tsx and .jsx files
      return id.match(/\.[tj]sx$/)
    },
    async transform(code, id, { uno }) {
      // code is a MagicString instance
      code.appendRight(0, '/* my transformer */')
    },
  }
}

आप अधिक उदाहरणों के लिए आधिकारिक ट्रांसफॉर्मर्स देख सकते हैं।

Released under the MIT License.