0👍
The .env
files (including .env.development
) must be manually added to your project directory. However, you don’t need them to set BASE_URL
, as BASE_URL
is automatically set from the base
config in vite.config.js
:
import { defineConfig } from 'vite'
export default defineConfig({
base: process.env.NODE_ENV === 'development'
? '/my/dev/baseurl/'
: '/my/prod/baseurl/',
})
To reference environment variables in source, use import.meta.env
instead of process.env
:
// createWebHistory(process.env.BASE_URL), ❌
createWebHistory(import.meta.env.BASE_URL), ✅
- [Vuejs]-Ionic Vue pass Object via router-link
- [Vuejs]-Fabric JS Canvas loses editability and resizability when assigned to Vue data attribute
Source:stackexchange.com