Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin wrongly thinks Vite is in production mode #51

Open
LeBenLeBen opened this issue Nov 12, 2024 · 3 comments
Open

Plugin wrongly thinks Vite is in production mode #51

LeBenLeBen opened this issue Nov 12, 2024 · 3 comments

Comments

@LeBenLeBen
Copy link
Contributor

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?

@arnoson
Copy link
Owner

arnoson commented Nov 12, 2024

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.

@LeBenLeBen
Copy link
Contributor Author

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.

@arnoson
Copy link
Owner

arnoson commented Nov 18, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants