Skip to content

Commit

Permalink
feat(utils): extraTransformTargets support custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 15, 2021
1 parent 6dac37a commit 7ee2de7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-utils/src/createUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-utils/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))[]
}
}

Expand Down

0 comments on commit 7ee2de7

Please sign in to comment.