UNPKG

ts-transform-css-modules

Version:
47 lines (46 loc) 1.57 kB
import * as ts from "typescript"; export declare type GenerateScopedNameFn = (name: string, filepath: string, css: string) => string; /** * Primarily from https://github.com/css-modules/css-modules-require-hook * * @export * @interface Opts */ export interface Opts { devMode?: boolean; extensions?: string[]; ignore?: string | Function | RegExp; preprocessCss?(css: string, filePath: string): string; processCss?(css: string, filePath: string): string; processorOpts?: object; camelCase?: boolean | "dashes" | "only" | "dashesOnly"; append?: any[]; prepend?: any[]; use?: any[]; createImportedName?: Function; generateScopedName?: string | GenerateScopedNameFn; hashPrefix?: string; mode?: string; rootDir?: string; resolve?: { alias?: { [path: string]: string; }; extensions?: string[]; modules?: string[]; mainFile?: string; preserveSymlinks?: boolean; }; /** * Custom resolver for css import declaration. This is primarily used * for project that uses absolute import. * When https://github.com/Microsoft/TypeScript/issues/28276 is fixed this * might not be necessary. * * @param {string} path path to be resolved * @returns {string} resolved path. Returning invalid string will fall back to our default resolver. * @memberof Opts */ tsImportResolver?(path: string): string; } export default function (opts?: Opts): (ctx: ts.TransformationContext) => ts.Transformer<ts.SourceFile>;