A simple plugin of vite for prefetch images.
pnpm add vite-plugin-image-prefetch -D
In vite.config.ts
:
import { vitePluginPrefetchImages } from 'vite-plugin-image-prefetch'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
vitePluginPrefetchImages({
dir: 'images/**/*.{jpg,jpeg,png,svg}'
})
]
})