Vite · Assets
VITE0001Keep new URL asset paths analyzable
Flags dynamic new URL in Vite assets code before it leaks into runtime behavior.
vite-doctor/viteassetswarnNo fix
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
Remove dynamic new URL, or move it to the Vite runtime/API that owns that behavior.
Example
Use static asset URLs
Before
const icon = new URL(`./icons/${name}.svg`, import.meta.url).href
After
const icons = {
home: new URL('./icons/home.svg', import.meta.url).href,
}
const icon = icons.home
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/assets/no-dynamic-new-url