UNPKG

ts-transform-img

Version:

Allow `import * as img from 'foo.png'` in TS

29 lines (28 loc) 770 B
import * as ts from 'typescript'; export declare type InterpolateNameFn = (filePath: string, content: Buffer) => string; /** * Options * * @export * @interface Opts */ export interface Opts { /** * Threshold of img that will be inlined */ threshold?: number; /** * Callback that gets triggered every time we encounter * an img import * @param params Map of asset ID to its path */ onImgExtracted(id: string, filePath: string): void; /** * webpack-style name interpolation * * @type {(InterpolateNameFn | string)} * @memberof Opts */ interpolateName?: InterpolateNameFn | string; } export default function (opts?: Opts): (ctx: ts.TransformationContext) => ts.Transformer<ts.SourceFile>;