Closed wucdbm closed 2 years ago
I don't really remember what was the reason to have false
as the default 🤔
In any case, you can override that. I think by just passing it to Vite as a normal option should affect both front and backends. Otherwise, you can pass options only for the frontend build in Vite SSR plugin:
viteSSR({
build: {
clientOptions: {
build: {
emptyOutDir: true
}
}
}
})
Hmpf, you're right. I had tested with server only, however, after drilling into the source code, I just realized that the output directory when building with this library isn't ~/dist
, but ~/dist/client
and ~/dist/server
So what I'll do is clear both.
However, as part of my build process, what I'm trying to achieve is to have the client as static files uploaded somewhere on a server, and for SSR - a single-file binary via pkg
. So I'm building the server with pkg successfully and then moving it into the ~/dist
directory. And somewhat naively thought I'd have the option to clear the whole directory via a single option.
Do you think it's worthwhile investing into an option to clear ~/dist
, or rather to leave it to user code to achieve that?
PS I hadn't noticed the options merge in the source, hence why I thought it was hardcoded -- was just a default, for anyone else wondering.
Is that on purpose, can we allow it to be controllable on the client build seeing as it runs first, and hardcode false for the server build as we can't clear it at that point?