Skip to content

Vite Plugin not respecting Vite env configuration #12849

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

Closed
andrew-canvette opened this issue Jan 23, 2025 · 3 comments
Closed

Vite Plugin not respecting Vite env configuration #12849

andrew-canvette opened this issue Jan 23, 2025 · 3 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

Copy link
Contributor

🤖 Hello there,

We just published version 7.2.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.2.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

github-actions bot commented Mar 6, 2025

🤖 Hello there,

We just published version 7.3.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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