Skip to content

Configuration and Environment Variables ​

Configuration layers ​

Project configuration is divided into three layers:

LayerFilePurpose
Build environmentapps/admin/.env.*API URLs, deployment paths, and build output
Application flagsapps/admin/src/config/app.tsUI capabilities such as Breadcrumb, TagsView, theme, and footer
Runtime stateapps/admin/src/store/modules/app.tsCurrent layout, collapse state, theme, and mobile state

Put build-time constants in environment variables, product flags that do not vary by environment in appConfig, and state that users can change at runtime in the Store.

Build modes ​

ModeFileOutput directoryBase
Local.env.baseDevelopment server/
Development.env.devdist-dev/dist-dev/
Test.env.testdist-test/dist-test/
Production.env.prodist-pro/

The environment files live under apps/admin because that application—not the repository root—is Vite's working directory.

Environment variables ​

VariableDescription
VITE_API_BASE_PATHAxios baseURL
VITE_BASE_PATHVite public base path
VITE_APP_TITLEDocument title and application title
VITE_SOURCEMAPWhether to emit sourcemaps
VITE_OUT_DIRBuild output directory
VITE_USE_MOCKWhether to enable the development Mock plugin
VITE_USE_CSS_SPLITWhether to split CSS

Only variables whose names begin with VITE_ are exposed to browser code. When adding a variable, update apps/admin/types/env.d.ts as well:

ts
interface ImportMetaEnv {
  readonly VITE_EXAMPLE: string
}

Environment variables are always read as strings. Convert boolean settings consistently with value === 'true'; do not rely on string truthiness.

Application UI configuration ​

src/config/app.ts contains capability flags that users cannot change. The fields currently connected to the layout are:

ts
export const appConfig = {
  title: import.meta.env.VITE_APP_TITLE,
  ui: {
    breadcrumb: true,
    breadcrumbIcon: true,
    hamburger: true,
    theme: true,
    locale: true,
    tagsViewIcon: true,
    footer: true,
    uniqueOpened: false
  }
} as const

When uniqueOpened is true, only one top-level branch of a vertical menu can remain expanded at a time.

Runtime state ​

The App Store contains:

  • layout: sidebar | top | mixed | dual
  • collapse: whether the sidebar is collapsed
  • isDark: whether dark mode is active
  • mobile: whether the current viewport is narrower than 768px
  • pageLoading: route-transition loading state

layout, collapse, and isDark are persisted to vea-app-v2; mobile and pageLoading belong only to the current session.

API proxy ​

By default, the development server proxies /api to http://127.0.0.1:8000:

ts
server: {
  proxy: {
    '/api': {
      target: 'http://127.0.0.1:8000',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/api/, '')
    }
  }
}

In a real project, VITE_API_BASE_PATH is commonly set to /api. The development proxy handles cross-origin requests locally, while the production gateway forwards them after deployment.

Changing the deployment subpath ​

When deploying to https://example.com/admin/, set:

dotenv
VITE_BASE_PATH=/admin/

The Router currently uses Hash History, so the static server does not need an HTML fallback for every business URL. It must, however, serve static assets from the configured Base path.

Keep the core for real business and stay restrained for unknown requirements.