Skip to content

Cannot switch environment variables based on the vite.config mode #14361

@r-matsuura

Description

@r-matsuura

Reproduction

  1. Go to https://stackblitz.com/edit/github-wnsaut53-hqy7cln6
  2. Run build command npm run build
  3. Check the built assets. The target is /build/client/assets/home-CifgD6Ro.js.
Image

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @react-router/dev: ^7.7.1 => 7.9.1 
    @react-router/node: ^7.7.1 => 7.9.1 
    @react-router/serve: ^7.7.1 => 7.9.1 
    react-router: ^7.7.1 => 7.9.1 
    vite: ^6.3.3 => 6.3.6

Used Package Manager

npm

Expected Behavior

Check the built assets, the environment variables for mode: production are referenced.

Actual Behavior

Check the built assets, the environment variables for mode: staging are referenced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions