Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite Plugin not respecting Vite env configuration #12849

Open
andrew-canvette opened this issue Jan 23, 2025 · 0 comments
Open

Vite Plugin not respecting Vite env configuration #12849

andrew-canvette opened this issue Jan 23, 2025 · 0 comments
Labels

Comments

@andrew-canvette
Copy link

I'm using React Router as a...

library

Reproduction

https://stackblitz.com/edit/remix-run-remix-cyw8eahe?file=app%2Froutes%2F_index.tsx

  1. Create directory ./env
  2. Create ./env/.env
  3. Add envDir: './env', to vite.config.ts

React router does not use envDir to look up the file. It also does not respect envFile false when specified by an inline config to disable loading .env files.

System Info

System:
    OS: Linux 6.9 Pop!_OS 22.04 LTS
    CPU: (32) x64 AMD Ryzen 9 7950X3D 16-Core Processor
    Memory: 42.12 GB / 61.94 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
    pnpm: 10.0.0 - ~/.nvm/versions/node/v20.18.0/bin/pnpm
  Browsers:
    Chrome: 132.0.6834.110
  npmPackages:
    vite: 5.4.11 => 5.4.11

Used Package Manager

npm

Expected Behavior

The vite plugin should respect environment configurations supplied to vite.

envFile from https://vite.dev/guide/api-javascript.html#inlineconfig

envDir from https://github.com/vitejs/vite/blob/f2c07dbfc874b46f6e09bb04996d0514663e4544/packages/vite/src/node/config.ts#L411

Actual Behavior

The plugin loads from the root no matter what, ignoring envFile and envDir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant