Env Variables and Modes#
The Vite
documentation for Env Variables and Modes
is available here.
Modes#
Development Mode#
Production Mode#
Environment#
Files#
.env # loaded in all cases
.env.development # only loaded in development mode
.env.production # only loaded in production mode
Danger
❗ Do not store sensitive information in .env
files. ❗
Sensitive variables can be stored in .env.*.local
files by adding it to your .gitignore to avoid them being
checked into git.
Variables#
Variable | Description | default | dev | prod |
---|---|---|---|---|
VITE_APP_TITLE | Title of the app in specific mode | PlantMap | [DEV] PlantMap | [PROD] PlantMap |
VITE_AUTH_REQUIRED | false/true, if auth is requried | false | false | true |
VITE_TOKEN_MAPBOX | Mapbox token | must be set | / | / |
VITE_TOKEN_OWM | OpenWeatherMap token | must be set | / | / |
Info
An env file for a specific mode (e.g. .env.production) will take higher priority than the generic .env
.
Environment variables that already exist when Vite is executed have the highest priority and will not be
overwritten by .env
files.
# vue/.env
VITE_APP_TITLE=PlantMap
VITE_AUTH_REQUIRED=false
VITE_TOKEN_MAPBOX= ... #SET TOKEN
VITE_TOKEN_OWM= ... #SET TOKEN
# vue/.env.development
VITE_APP_TITLE=[DEV] PlantMap
VITE_AUTH_REQUIRED=false
# vue/.env.production
VITE_APP_TITLE=[PROD] PlantMap
VITE_AUTH_REQUIRED=true