How to tell the development server and production server apart in a Vite project
While handling QA for a project today, I had to show a user with the same name on both the development server and the production server.
The key for loading that user was staffId, but the staffId value was different on the development server and the production server, so I needed to be able to tell them apart.
The doc I referred to is at the link below.
https://ko.vitejs.dev/guide/env-and-mode.html
import.meta.env.MODE -> If you log this with console.log(), it prints 'development' in the development environment, that is, when running locally, and prints 'production' when it isn't the development environment.
This is how I was able to solve the problem.
- #import.meta.env.MODE
- #Vite
- #development server
- #distinguish
- #production server