vite
vite copied to clipboard
feat: support warmup by IDs
Description
This PR implements the server.warmup.clientIds
and server.warmup.ssrIds
options, which are the IDs of modules to be warmed up. For example, ['virtual:custom']
.
Slidev's starting time is a little bit too long now, and to improve this, virtual modules like /@slidev/slides/3.md
should be warmed up. Currently, Vite's server.warmup.clientFiles
only accepts files, and there seem to be no other ways.
I am not 100% sure about the naming conventions in Vite. Should the option be clientIds
or clientUrls
?
Run & review this pull request in StackBlitz Codeflow.
I think we should go with url here. It feels a bit too much to have both clientFiles
and clientUrls
though. I wonder if we could keep only the urls somehow, making the patterns work. So it also better aligns with server.warmupRequest(url)
In Vite 6, we'll have an opportunity to review this API because we are moving it a dev environment config option. Currently it is:
export default defineConfig({
environments: {
client: {
dev: {
warmup: [files...]
}
}
}
})
So we can directly define that warmup are URLs. Or switch to an object if we need that.