# UnoCSS Documentation
# Source: https://raw.githubusercontent.com/unocss/unocss/main/docs/config/transformers.md
# Path: docs/config/transformers.md

# Transformers

Provides a unified interface to transform source code in order to support conventions.

```ts [my-transformer.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 */')
    },
  }
}
```

You can check [official transformers](/presets/#transformers) for more examples.