diff --git a/packages/plugin-utils/src/createUtils.ts b/packages/plugin-utils/src/createUtils.ts index 607288ce..5b7acfe9 100644 --- a/packages/plugin-utils/src/createUtils.ts +++ b/packages/plugin-utils/src/createUtils.ts @@ -126,7 +126,7 @@ export function createUtils( } function isDetectTarget(id: string) { - if (options.scanOptions.extraTransformTargets.detect.includes(id)) + if (options.scanOptions.extraTransformTargets.detect.some(i => typeof i === 'string' ? i === id : i(id))) return true if (files.includes(id) || files.includes(id.slice(0, id.indexOf('?')))) return true @@ -141,7 +141,7 @@ export function createUtils( } function isCssTransformTarget(id: string) { - if (options.scanOptions.extraTransformTargets.css.includes(id)) + if (options.scanOptions.extraTransformTargets.css.some(i => typeof i === 'string' ? i === id : i(id))) return true if (id.match(/\.(?:postcss|scss|sass|css|stylus|less)(?:$|\?)/i) && !isExcluded(id)) return true diff --git a/packages/plugin-utils/src/options.ts b/packages/plugin-utils/src/options.ts index 9f08d9b9..63bcc5ea 100644 --- a/packages/plugin-utils/src/options.ts +++ b/packages/plugin-utils/src/options.ts @@ -262,8 +262,8 @@ export interface ResolvedOptions { transformers: TransformerFunction[] extractors: Extractor[] extraTransformTargets: { - css: string[] - detect: string[] + css: (string | ((path: string) => boolean))[] + detect: (string | ((path: string) => boolean))[] } }