Skip to content

Glob Patterns

Glob patterns are used all throughout the package’s configuration to determine whether a path/file should have some specific behavior applied to it. For the most part, the package makes use of the fast-glob syntax, with one notable exception. If you want to test out some glob patterns, there is a playground available.

Basic Syntax

  • * matches any character, except for / and hidden files (starting with .).
  • ** matches zero or more directories
  • ? matches a single character, except for /
  • [seq] matches any character in seq

Only matches a file in the root directory (because / are not matched).

  • page.md
  • script.js
  • Directorysome
    • Directorydir
      • important.ts
      • file.md
      • .hidden.md
    • Directoryother-dir
      • note.mdx
      • regular.md

Advanced Syntax

  • ?(a|b) matches a or b (zero or one times)
  • *(a|b) matches a or b (zero or more times)
  • +(a|b) matches a or b (one or more times)
  • @(a|b) matches a or b (exactly one time)
  • !(a|b) matches anything except a or b

Pattern processing

  • Patterns are processed in the order they are defined.
  • The first pattern that matches the file path will be used to determine the behavior.
  • If a ! is present at the start of the pattern, the behavior will be negated.

Some examples:

Matches all files.

  • page.md
  • script.js
  • Directorysome
    • Directorydir
      • important.ts
      • file.md
      • .hidden.md
    • Directoryother-dir
      • note.mdx
      • regular.md