Skip to content

Vite MODE when evaluating routes.ts is production/development, not what’s passed via --mode #12514

@fionawhim

Description

@fionawhim

I'm using React Router as a...

framework

Reproduction

Example repo: https://github.com/fionawhim/rr-mode-bug

(this is based off of create-react-router)

  • npm install, &c.
  • npm run build -- --mode=staging

System Info

System:
    OS: macOS 14.7.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 60.05 MB / 16.00 GB
    Shell: 3.7.1 - /usr/local/bin/fish
  Binaries:
    Node: 18.16.0 - ~/.asdf/installs/nodejs/lts-hydrogen/bin/node
    npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 131.0.6778.109
    Safari: 18.1.1
  npmPackages:
    @react-router/dev: ^7.0.2 => 7.0.2 
    @react-router/node: ^7.0.2 => 7.0.2 
    @react-router/serve: ^7.0.2 => 7.0.2 
    react-router: ^7.0.2 => 7.0.2 
    vite: ^5.4.11 => 5.4.11

Used Package Manager

npm

Expected Behavior

This code console.logs the Vite “mode” in both vite.config.ts and routes.ts.

The --mode set on the command line should be echoed in both places. In this case, each should say “staging”

Actual Behavior

Instead, the Vite mode for routes.ts is always production when doing a build (and development when doing dev server)

MODE FOR VITE CONFIG staging
MODE FOR ROUTES: production
MODE FOR VITE CONFIG staging

The rational here is to have routes that are generated in our staging environment but not our production environment.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions