Skip to content

🚀 Feature Request: Support exclude patterns in [build].watch_dir #10970

@XIYO

Description

@XIYO

Problem

When using code generators like paraglide-js (i18n), graphql-codegen, or prisma, wrangler's custom build watch triggers infinite rebuild loops because generated files are detected as changes.

Current Behavior

[build]
command = "pnpm build"
watch_dir = "src"

What happens:

  1. Build generates files in src/lib/paraglide/
  2. Wrangler detects file changes in watch_dir
  3. Triggers rebuild
  4. Build generates files again
  5. Infinite loop 🔄

Additionally:

  • .gitignore patterns are not respected by watch
  • No way to exclude subdirectories from watch

Proposed Solution

Option 1: Add watch_ignore parameter

[build]
command = "pnpm build"
watch_dir = "src"
watch_ignore = ["src/lib/paraglide/**", "**/.svelte-kit/**"]

Option 2: Automatically respect .gitignore

Wrangler should automatically exclude paths listed in .gitignore from the watch mechanism.

Use Cases

This affects any project using code generators:

  • i18n: paraglide-js, typesafe-i18n
  • GraphQL: graphql-codegen
  • ORM: prisma client generate
  • Type generation: openapi-typescript
  • Build artifacts: .svelte-kit, .next, etc.

Current Workaround

Users must manually run build before dev:

pnpm build && pnpm wrangler dev --port 8788

This removes the benefit of automatic rebuilds on file changes.

Related Issues

Environment

  • wrangler: 4.42.2
  • Framework: SvelteKit
  • Adapter: @sveltejs/adapter-cloudflare

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions