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

env variables not expanded in .env file #10040

Closed
7 tasks done
FezVrasta opened this issue Sep 8, 2022 · 2 comments
Closed
7 tasks done

env variables not expanded in .env file #10040

FezVrasta opened this issue Sep 8, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@FezVrasta
Copy link

FezVrasta commented Sep 8, 2022

Describe the bug

We recently migrated from Create React App to Vite and we are encountering issues with the way dotenv and dotenv-expand is configured.

Our .env file used to look like this:

REACT_APP_DEPLOY_ENV=$DEPLOY_ENV

This allowed our app to read the global DEPLOY_ENV variable as REACT_APP_DEPLOY_ENV.

We changed it to:

VITE_DEPLOY_ENV=$DEPLOY_ENV

But the VITE_ prefixed variable is never defined.

I don't think this is intended, as dotenv-expand should have access to the environment variables in order to work, but right now it doesn't seem to work.

Note that this example doesn't work either:

VITE_NOT_WORKING=$VITE_WORKING

In this last example import.meta.env.VITE_WORKING will work but import.meta.env.VITE_NOT_WORKING will be empty.

Reproduction

https://stackblitz.com/edit/vitejs-vite-6jvttl?file=main.js

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vite: ^3.1.0 => 3.1.0 

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red
Copy link
Member

Duplicate of #6626

@sapphi-red sapphi-red marked this as a duplicate of #6626 Sep 8, 2022
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Sep 8, 2022
@FezVrasta
Copy link
Author

Oh right, thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants