Open LeBenLeBen opened 1 week ago
I have the same setup (building locally and then transfering all files to the server). Kirby Vite checks for a .dev
file in the root folder to determine wether or not it is in dev mode, so you don't have to delete the dist/outDir folder to force it into dev mode. Building removes the .dev
file and running npm run dev
will create it again.
Normally I just run everything in on terminal window, so for deploying/building I stop the dev server first, run my deployment, and then start it again. Since I usually don't deploy many times a day, I didn't mind stopping/restarting the dev server.
So I guess you want to keep the dev version running in one process while deploying in another process? I guess we could add a option to the vite plugin to prevent removing the .dev
file on build (ideally only if a dev server is running at the time of the build), otherwise it would make it harder to preview the build locally where we want the .dev
file to be removed.
Yeah it’s exactly that, Vite continues to run in dev mode. In my case it happens because I use Docker and it requires the container to have a command running to stay up. I run the build command in the container in parallel of the server.
Ah okay, i use docker with DDEV which stays up once it started. But to support your use case I'm open for a PR (since I don't have much time right now). I would like to avoid a config flag that prevents the .dev
file from being deleted since this could confuse people and wouldn't allow to preview builds locally. Ideally it would be great to either determine wether the dev server is still running (but I'm not sure if this could be done easily) or remove the .dev
file when vite dev stops instead of doing this on a build start (should be easy to listen for the process to stop in the plugin). What do you think?
During my deployment process, I build Vite assets locally and transfer them to the server afterwards, so I don’t need to have Node & all the assets pipeline installed on the server.
This process writes the files on disk at the expected
build.outDir
location, making kirby-vite think it’s in production mode afterwards. This behavior forces me to manually delete the dist folder and restart the server after every deployment to pick up new changes.I appreciate the fact it works seamlessly out of the box, but I think it would be great to have a setting to be able to enforce one mode or the other for such cases. Would you be open to such feature?