Vite · Workers

VITE0021Use Vite's static worker URL pattern

Checks that Vite worker code includes the worker URL pattern needed for predictable behavior.

Why it happens

Vite configuration runs in both dev and build pipelines. Narrow, explicit settings reduce surprises across SSR, workers, and local file access.

Fix

Add worker URL pattern where Vite expects it, close to the code that depends on it.

Example

Use Vite worker URL pattern

Before

const worker = new Worker('./worker.ts')

After

const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' })

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vite --rules vite/worker/require-worker-url-pattern
Copyright © 2026