|
1 | | -import type MagicString from 'magic-string' |
2 | | -import type { SourceCodeTransformer, UnoGenerator } from 'unocss' |
| 1 | +import type { SourceCodeTransformer } from 'unocss' |
| 2 | +import type { TransformerCssUrlRebaseOptions } from './options' |
| 3 | +import { withTransformCssUrlRebase } from './transform' |
3 | 4 |
|
4 | | -export interface TransformerStarterOptions { |
5 | | - |
6 | | -} |
7 | | - |
8 | | -export default function transformStarter(options?: TransformerStarterOptions): SourceCodeTransformer { |
| 5 | +export function transformerCssUrlRebase(options?: TransformerCssUrlRebaseOptions): SourceCodeTransformer { |
9 | 6 | return { |
10 | | - name: 'unocss-transformer-starter', |
| 7 | + name: 'unocss-transformer-css-url-rebase', |
11 | 8 | enforce: 'pre', |
12 | | - async transform(code, _, { uno }) { |
13 | | - await transformStarterMain(code, uno, options) |
| 9 | + transform(code, id, { root }) { |
| 10 | + const highlightAnnotations = withTransformCssUrlRebase(code, id, undefined, Object.assign({ root }, options)) |
| 11 | + return { highlightAnnotations } |
14 | 12 | }, |
15 | 13 | } |
16 | 14 | } |
17 | 15 |
|
18 | | -export async function transformStarterMain( |
19 | | - code: MagicString, |
20 | | - uno: UnoGenerator, |
21 | | - // eslint-disable-next-line unused-imports/no-unused-vars |
22 | | - options: TransformerStarterOptions = {}, |
23 | | -) { |
24 | | - // Your logic here |
25 | | - code.replace('UnoCSS', 'UnoCSS is awesome') |
26 | | -} |
| 16 | +export default transformerCssUrlRebase |
| 17 | + |
| 18 | +export { withTransformCssUrlRebase } |
0 commit comments