Skip to content

FileMatchers

FileMatchers = MaybeArray<FileMatcher>

Defined in: types.ts:320

A single instance or an array of file matchers in following formats:

  1. File name: image.svg.

  2. Path to a file from the project’s root: /src/assets/image.svg.

  3. RegExp: tested against file name (image.svg) and relative path (/src/assets/image.svg).

  4. Function (FileMatcherFn) that accepts information about a file and returns true, if line width should be preserved.

All paths use forward slash (/) as a separator. Relative paths start with /.

Recommendation: Include path information and use clean project structure to avoid unintentional matches.

const matchers: FileMatchers = [
// Any file named "image.svg"
"image.svg",
// Specific file
"/src/assets/image.svg",
// Any path containing "/some/directory/"
new RegExp("\/some\/directory\/"),
// Any file ending with "-image.svg"
new RegExp("\\-image\\.svg$"),
// Any path containing "/some/directory/" or any file ending with "-image.svg"
(ctx) => ctx.relativePath.includes("/some/directory/") || ctx.fullPath.endsWith("-image.svg"),
];