Skip to content

Sanity CLI --watchPatterns doesn't seem to be working with wildcards #1139

Open

Description

@nienna73

If you find a security vulnerability, do NOT open an issue. Email security@sanity.io instead.

Describe the bug

I'm having trouble getting the watchPatterns option for schema extraction to work with wildcards. I want to run sanity schema extract --watch concurrently with my local dev server so the schema and types can update automatically as I work.

To Reproduce

I'm running an embedded sanity studio within a Next.js app. My sanity files are all located at src/sanity with the schema types in src/sanity/schemaTypes. My sanity.cli.ts file is located at the root of my project and looks something like this:

import { defineCliConfig } from "sanity/cli";

export default defineCliConfig({
    api: {
        projectId,
        dataset,
    },
    typegen: {
        enabled: true,
        path: "src/app/**/*.{ts,tsx}",
        schema: "./schema.json",
        generates: "src/sanity/types.ts",
    },
    schemaExtraction: {
        enabled: true,
        watchPatterns: [
          "src/sanity/schemaTypes/**/*.{ts,tsx}",
        ],
    }
});

Steps to reproduce the behavior with this configuration:

  1. Start from the command line within a sanity project
  2. Run sanity schema extract --watch from the root of the project
  3. Modify a file in the src/sanity/schemaTypes directory

Expected behavior

Modifying the file should trigger the schema extraction. Instead the change is not registered.

Which versions of Sanity are you using?

@sanity/cli (global)   6.5.0 (latest: 6.6.0)
@sanity/image-url      2.1.1 (up to date)
@sanity/vision        5.24.0 (latest: 5.27.0)
sanity                5.24.0 (latest: 5.27.0)
@sanity/client        7.22.0 (up to date)

What operating system are you using?

MacOS Tahoe 26.4

Which versions of Node.js / npm are you running?

npm version 11.12.1
node version 26.0.0

Additional context

Things I've tried that did not work:

  • watchPatterns: ["src/sanity/schemaTypes/sampleType.{ts,tsx}"]
  • watchPatterns: ["src/sanity/schemaTypes/**/*.{ts,tsx}"]

The only thing that has worked:

  • watchPatterns: ["src/sanity/schemaTypes/sampleType.ts"] where "sampleType.ts" is a real file in that directory

Security issue?

No discernible security issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions